Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for private groups reopening and fixing room subscription state #765

Merged
merged 4 commits into from
Sep 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions client/methods/openRoom.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Meteor.methods
openRoom: (rid) ->
if not Meteor.userId()
throw new Meteor.Error 'invalid-user', '[methods] openRoom -> Invalid user'

ChatSubscription.update
rid: rid
'u._id': Meteor.userId()
,
$set:
open: true
2 changes: 2 additions & 0 deletions client/routes/roomRoute.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ openRoom = (type, name) ->
$('.message-form .input-message').focus()
, 100

# update user's room subscription
Meteor.call 'openRoom', room._id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update subscription every time user enter in a room’s route don't seems to be a good idea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rodrigok what about this?

# update user's room subscription
if ChatSubscription.findOne({rid: room._id})?.open is false
    Meteor.call 'openRoom', room._id

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marceloschmidt looks good, but already was merged 😢


roomExit = ->
mainNode = document.querySelector('.main-content')
Expand Down
19 changes: 19 additions & 0 deletions client/views/app/sideNav/listPrivateGroupsFlex.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Template.listPrivateGroupsFlex.helpers
groups: ->
return ChatSubscription.find { t: { $in: ['p']}, f: { $ne: true } }, { sort: 't': 1, 'name': 1 }

Template.listPrivateGroupsFlex.events
'click header': ->
SideNav.closeFlex()

'click .channel-link': ->
SideNav.closeFlex()

'click footer .create': ->
SideNav.setFlex "createChannelFlex"

'mouseenter header': ->
SideNav.overArrow()

'mouseleave header': ->
SideNav.leaveArrow()
27 changes: 27 additions & 0 deletions client/views/app/sideNav/listPrivateGroupsFlex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template name="listPrivateGroupsFlex">
<header>
<div>
<h4>{{_ "Private_Groups"}}</h4>
</div>
</header>
<div class="content">
<div class="wrapper">
<h4>{{_ "Private_Groups_list"}}</h4>
<ul>
{{#each groups}}
<li>
<a href="{{pathFor 'group' name=name}}" class="channel-link">
<i class="icon-lock"></i>
{{name}}
</a>
</li>
{{/each}}
</ul>
</div>
</div>
<footer>
<div>
<button class="button clean create">{{_ "Create_new"}}</button>
</div>
</footer>
</template>
4 changes: 4 additions & 0 deletions client/views/app/sideNav/privateGroups.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ Template.privateGroups.events
'click .add-room': (e, instance) ->
SideNav.setFlex "privateGroupsFlex"
SideNav.openFlex()

'click .more-groups': ->
SideNav.setFlex "listPrivateGroupsFlex"
SideNav.openFlex()
1 change: 1 addition & 0 deletions client/views/app/sideNav/privateGroups.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ <h3 class="add-room {{isActive}}">
<p class="empty">{{_ "No_groups_yet" }}</p>
{{/each}}
</ul>
<a href="" class="more more-groups">{{_ "More_groups"}} ..</a>
</template>
2 changes: 2 additions & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"Meta_robots" : "Robots",
"minutes" : "minutes",
"More_channels" : "More channels",
"More_groups" : "More private groups",
"More_unreads" : "More unreads",
"Msgs" : "Msgs",
"multi" : "multi",
Expand Down Expand Up @@ -205,6 +206,7 @@
"Preferences_saved" : "Preferences saved",
"Privacy" : "Privacy",
"Private_Groups" : "Private Groups",
"Private_Groups_list" : "List of Private Groups",
"Profile" : "Profile",
"Profile_saved_successfully" : "Profile saved successfully",
"Proudly_developed" : "Proudly developed with Meteor",
Expand Down
2 changes: 2 additions & 0 deletions i18n/pt.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
"Meta_robots" : "Robots",
"minutes" : "minutos",
"More_channels" : "Mais canais",
"More_groups" : "Mais grupos privados",
"Msgs" : "Msgs",
"multi" : "multi",
"My_Account" : "Minha Conta",
Expand Down Expand Up @@ -198,6 +199,7 @@
"Preferences_saved" : "Preferências salvas",
"Privacy" : "Privacidade",
"Private_Groups" : "Grupos Privados",
"Private_Groups_list" : "Lista de Grupos Privados",
"Profile" : "Perfil",
"Profile_saved_successfully" : "Perfil salvo com sucesso",
"Proudly_developed" : "Orgulhosamente desenvolvido com Meteor",
Expand Down
13 changes: 13 additions & 0 deletions server/methods/openRoom.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Meteor.methods
openRoom: (rid) ->
if not Meteor.userId()
throw new Meteor.Error 'invalid-user', '[methods] openRoom -> Invalid user'

console.log '[methods] openRoom -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments

ChatSubscription.update
rid: rid
'u._id': Meteor.userId()
,
$set:
open: true