-
Notifications
You must be signed in to change notification settings - Fork 3
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
[WIP] threads review/adjustments #572
Changes from 4 commits
46f65b4
6da53aa
0fe376f
c2f7fbb
f8f4c96
74392fa
c953ad6
9443868
0466e1b
fa889d4
f8caa84
ab8c169
2332f0e
5c964e2
00c59f2
0369f89
af87678
8a7fa76
e1e7507
cdfc3c0
5f0180d
61debea
5addfc4
23942a8
b96b825
361ca5b
9eeee74
b878efa
c5edd57
79edb4c
50adf45
f04fbf7
b16fe93
8f40051
8bddc37
576c38a
36a0fc3
fd47795
2f94689
9672b4f
3e28428
84633d2
0105b8d
39e8fe1
474c918
d0e0325
dcc9b3e
54b8dbd
2e9b0ff
afdfd75
1343fe6
5ec74ad
e7227de
561a851
5bd7e12
2aa0562
bdde3f8
5787fb2
dc51cdc
a080cd9
76b5f7f
02c6312
fe9f809
074a712
22002de
773ed6f
1e54d65
46b5231
6ec15c8
dce3144
d656657
7773fa6
d005119
2c68516
09ae45c
8b57358
782b007
33a3a6f
16e90e2
4045d3d
98d40c0
a4ce2d0
f933e59
3885401
30900b7
881980e
108c13b
359b12e
574b96f
d2be600
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,37 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Tracker } from 'meteor/tracker'; | ||
import { RocketChat } from 'meteor/rocketchat:lib'; | ||
import { FlowRouter } from 'meteor/kadira:flow-router'; | ||
import { ReactiveVar } from 'meteor/reactive-var'; | ||
import { Tracker } from 'meteor/tracker'; | ||
import { ChatMessage } from 'meteor/rocketchat:models'; | ||
import { call } from 'meteor/rocketchat:lib'; | ||
|
||
const condition = (rid, uid) => { | ||
if (!RocketChat.models.Subscriptions.findOne({ rid })) { | ||
return false; | ||
} | ||
return uid !== Meteor.userId() ? RocketChat.authz.hasPermission('start-thread-other-user') : RocketChat.authz.hasPermission('start-thread'); | ||
}; | ||
|
||
Meteor.startup(function() { | ||
const instance = this; | ||
instance.room = new ReactiveVar(''); | ||
RocketChat.MessageAction.addButton({ | ||
id: 'start-thread', | ||
icon: 'thread', | ||
label: 'Thread_start', | ||
context: ['message', 'message-mobile'], | ||
action() { | ||
const message = this._arguments[1]; | ||
Meteor.call('createThreadFromMessage', message, function(error, result) { | ||
if (result) { | ||
// remove the hidden message from the UI - the message list is not reactive | ||
Tracker.nonreactive(function() { | ||
ChatMessage.remove({ | ||
_id: message._id, | ||
}); | ||
}); | ||
Tracker.autorun(() => { | ||
if (RocketChat.settings.get('Thread_from_context_menu') !== 'button') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. much better... Kind-of-ashamed... |
||
return RocketChat.MessageAction.removeButton('start-thread'); | ||
} | ||
|
||
// navigate to the newly created room | ||
FlowRouter.goToRoomById(result._id); | ||
} | ||
}); | ||
}, | ||
condition(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
if (RocketChat.settings.get('Thread_from_context_menu') !== 'button') { | ||
return false; | ||
} | ||
if (message.u._id !== Meteor.userId()) { | ||
return RocketChat.authz.hasAtLeastOnePermission('start-thread-other-user'); | ||
} else { | ||
return RocketChat.authz.hasAtLeastOnePermission('start-thread'); | ||
} | ||
}, | ||
order: 0, | ||
group: 'menu', | ||
RocketChat.MessageAction.addButton({ | ||
id: 'start-thread', | ||
icon: 'thread', | ||
label: 'Thread_start', | ||
context: ['message', 'message-mobile'], | ||
async action() { | ||
const [, message] = this._arguments; | ||
const { _id } = await call('createThreadFromMessage', message); | ||
FlowRouter.goToRoomById(_id); | ||
}, | ||
condition({ rid, u: { _id: uid } }) { | ||
return condition(rid, uid); | ||
}, | ||
order: 0, | ||
group: 'menu', | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { RocketChat } from 'meteor/rocketchat:lib'; | ||
import { FlowRouter } from 'meteor/kadira:flow-router'; | ||
import { Tracker } from 'meteor/tracker'; | ||
|
||
RocketChat.messageBox.actions.add('Create_new', 'Thread', { | ||
id: 'start-thread', | ||
icon: 'thread', | ||
condition: () => (navigator.getUserMedia || navigator.webkitGetUserMedia) && RocketChat.settings.get('FileUpload_Enabled') && RocketChat.settings.get('Message_VideoRecorderEnabled') && (!RocketChat.settings.get('FileUpload_MediaTypeWhiteList') || RocketChat.settings.get('FileUpload_MediaTypeWhiteList').match(/video\/webm|video\/\*/i)), | ||
action() { | ||
return FlowRouter.go('create-thread'); | ||
}, | ||
Meteor.startup(function() { | ||
Tracker.autorun(() => { | ||
if (RocketChat.settings.get('Thread_from_context_menu') !== 'button') { | ||
return RocketChat.messageBox.actions.remove('Create_new'); | ||
} | ||
RocketChat.messageBox.actions.add('Create_new', 'Thread', { | ||
id: 'start-thread', | ||
icon: 'thread', | ||
condition: () => true, | ||
action() { | ||
return FlowRouter.go('create-thread'); | ||
}, | ||
}); | ||
|
||
}); | ||
}); |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,6 @@ | |
<aside class="sidebar sidebar--{{sidebarViewMode}} {{#if sidebarHideAvatar}}sidebar--hide-avatar{{/if}}" role="navigation"> | ||
{{> sidebarHeader }} | ||
{{#if loggedInUser}} | ||
{{#if threadingFromSidebar}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I absolutely understand you didn't like that button - I don't like it either. But: Is there a replacement for that? I believe there should be an option to start a thread without opening the room first. |
||
<button class="create-thread-sidebar-button rc-button rc-button--primary js-create-thread">{{> icon icon="plus"}} {{_ "Thread_start"}}</button> | ||
{{/if}} | ||
<div class="unread-rooms background-primary-action-color color-primary-action-contrast top-unread-rooms hidden"> | ||
{{_ "More_unreads"}} <i class="icon-up-big"></i> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,6 @@ Template.sideNav.helpers({ | |
return String(settings.get('Layout_Sidenav_Footer')).trim(); | ||
}, | ||
|
||
threadingFromSidebar() { | ||
return RocketChat.authz.hasPermission('start-thread') && RocketChat.getUserPreference(Meteor.userId(), 'sidebarShowThreads') && !Meteor.isCordova; | ||
}, | ||
|
||
roomType() { | ||
return roomTypes.getTypes().map((roomType) => ({ | ||
template: roomType.customTemplate || 'roomList', | ||
|
@@ -68,10 +64,6 @@ Template.sideNav.events({ | |
'dropped .sidebar'(e) { | ||
return e.preventDefault(); | ||
}, | ||
|
||
'click .js-create-thread'() { | ||
return FlowRouter.go('create-thread'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you left the route, as far as I can see. 👍 |
||
}, | ||
}); | ||
|
||
Template.sideNav.onRendered(function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you not like the slash command? I use it frequently myself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will reinsert :)