Skip to content

Commit 34e32e1

Browse files
Fixed pin and star
1 parent aace1ad commit 34e32e1

7 files changed

Lines changed: 27 additions & 60 deletions

File tree

‎client/methods/pinMessage.coffee‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎client/methods/unpinMessage.coffee‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎packages/rocketchat-message-pin/client/actionButton.coffee‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Meteor.startup ->
44
icon: 'icon-pin'
55
i18nLabel: 'Pin_Message'
66
action: (event, instance) ->
7-
event.preventDefault()
8-
event.stopPropagation()
97
message = @_arguments[1]
108
message.pinned = true
119
Meteor.call 'pinMessage', message, (error, result) ->
@@ -26,8 +24,6 @@ Meteor.startup ->
2624
icon: 'icon-eraser'
2725
i18nLabel: 'Unpin_Message'
2826
action: (event, instance) ->
29-
event.preventDefault()
30-
event.stopPropagation()
3127
message = @_arguments[1]
3228
message.pinned = false
3329
Meteor.call 'unpinMessage', message, (error, result) ->
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Meteor.methods
2+
pinMessage: (message) ->
3+
if not Meteor.userId()
4+
throw new Meteor.Error('invalid-user', "[methods] pinMessage -> Invalid user")
5+
6+
if not RocketChat.settings.get 'Message_AllowPinning'
7+
throw new Meteor.Error 'message-pinning-not-allowed', '[methods] pinMessage -> Message pinning not allowed'
8+
9+
10+
ChatMessage.update
11+
_id: message._id
12+
,
13+
$set: { pinned: true }
14+
15+
unpinMessage: (message) ->
16+
if not Meteor.userId()
17+
throw new Meteor.Error('invalid-user', "[methods] pinMessage -> Invalid user")
18+
19+
if not RocketChat.settings.get 'Message_AllowPinning'
20+
throw new Meteor.Error 'message-pinning-not-allowed', '[methods] pinMessage -> Message pinning not allowed'
21+
22+
23+
ChatMessage.update
24+
_id: message._id
25+
,
26+
$set: { pinned: false }

‎packages/rocketchat-message-pin/package.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Package.onUse(function(api) {
1717
api.addFiles([
1818
'client/lib/PinnedMessage.coffee',
1919
'client/actionButton.coffee',
20+
'client/pinMessage.coffee',
2021
'client/tabBar.coffee',
2122
'client/views/pinnedMessages.html',
2223
'client/views/pinnedMessages.coffee',

‎packages/rocketchat-ui-message/message/message.coffee‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ Template.message.helpers
3939
# otherwise a special "?" character that will be
4040
# rendered as a special avatar
4141
return @editedBy?.username or "?"
42-
pinned: ->
43-
return this.pinned
4442
canEdit: ->
4543
hasPermission = RocketChat.authz.hasAtLeastOnePermission('edit-message', this.rid)
4644
isEditAllowed = RocketChat.settings.get 'Message_AllowEditing'
@@ -61,10 +59,6 @@ Template.message.helpers
6159
return true
6260

6361
return RocketChat.settings.get('Message_AllowDeleting') and this.u?._id is Meteor.userId()
64-
canPin: ->
65-
return RocketChat.settings.get 'Message_AllowPinning'
66-
canStar: ->
67-
return RocketChat.settings.get 'Message_AllowStarring'
6862
showEditedStatus: ->
6963
return RocketChat.settings.get 'Message_ShowEditedStatus'
7064
label: ->

‎packages/rocketchat-ui/views/app/room.coffee‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -377,14 +377,6 @@ Template.room.events
377377
ChatMessage.update {_id: this._arguments[1]._id, 'urls.url': $(event.currentTarget).data('url')}, {$set: {'urls.$.downloadImages': true}}
378378
ChatMessage.update {_id: this._arguments[1]._id, 'attachments.image_url': $(event.currentTarget).data('url')}, {$set: {'attachments.$.downloadImages': true}}
379379

380-
'click .pin-message': (event) ->
381-
message = @_arguments[1]
382-
instance = Template.instance()
383-
if message.pinned
384-
chatMessages[Session.get('openedRoom')].unpinMsg(message)
385-
else
386-
chatMessages[Session.get('openedRoom')].pinMsg(message)
387-
388380
'dragenter .dropzone': (e) ->
389381
e.currentTarget.classList.add 'over'
390382

0 commit comments

Comments
 (0)