-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6781 from RocketChat/message-star-to-js
Convert Message-Star Package to js
- Loading branch information
Showing
18 changed files
with
252 additions
and
194 deletions.
There are no files selected for viewing
83 changes: 0 additions & 83 deletions
83
packages/rocketchat-message-star/client/actionButton.coffee
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import toastr from 'toastr'; | ||
Meteor.startup(function() { | ||
RocketChat.MessageAction.addButton({ | ||
id: 'star-message', | ||
icon: 'icon-star-empty', | ||
i18nLabel: 'Star_Message', | ||
context: ['starred', 'message', 'message-mobile'], | ||
action() { | ||
const message = this._arguments[1]; | ||
message.starred = Meteor.userId(); | ||
return Meteor.call('starMessage', message, function(error) { | ||
if (error) { | ||
return handleError(error); | ||
} | ||
}); | ||
}, | ||
validation(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
return RocketChat.settings.get('Message_AllowStarring') && !message.starred; | ||
}, | ||
order: 10 | ||
}); | ||
RocketChat.MessageAction.addButton({ | ||
id: 'unstar-message', | ||
icon: 'icon-star', | ||
i18nLabel: 'Unstar_Message', | ||
context: ['starred', 'message', 'message-mobile'], | ||
action() { | ||
const message = this._arguments[1]; | ||
message.starred = false; | ||
return Meteor.call('starMessage', message, function(error) { | ||
if (error) { | ||
return handleError(error); | ||
} | ||
}); | ||
}, | ||
validation(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
return RocketChat.settings.get('Message_AllowStarring') && message.starred; | ||
}, | ||
order: 10 | ||
}); | ||
RocketChat.MessageAction.addButton({ | ||
id: 'jump-to-star-message', | ||
icon: 'icon-right-hand', | ||
i18nLabel: 'Jump_to_message', | ||
context: ['starred'], | ||
action() { | ||
const message = this._arguments[1]; | ||
RocketChat.MessageAction.hideDropDown(); | ||
return RoomHistoryManager.getSurroundingMessages(message, 50); | ||
}, | ||
validation(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
order: 100 | ||
}); | ||
return RocketChat.MessageAction.addButton({ | ||
id: 'permalink-star', | ||
icon: 'icon-link', | ||
i18nLabel: 'Permalink', | ||
classes: 'clipboard', | ||
context: ['starred'], | ||
action() { | ||
const message = this._arguments[1]; | ||
RocketChat.MessageAction.hideDropDown(); | ||
$(event.currentTarget).attr('data-clipboard-text', RocketChat.MessageAction.getPermaLink(message._id)); | ||
return toastr.success(TAPi18n.__('Copied')); | ||
}, | ||
validation(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
order: 101 | ||
}); | ||
}); |
1 change: 0 additions & 1 deletion
1
packages/rocketchat-message-star/client/lib/StarredMessage.coffee
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this.StarredMessage = new Mongo.Collection('rocketchat_starred_message'); |
15 changes: 0 additions & 15 deletions
15
packages/rocketchat-message-star/client/starMessage.coffee
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Meteor.methods({ | ||
starMessage(message) { | ||
if (!Meteor.userId()) { | ||
return false; | ||
} | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
if (!RocketChat.settings.get('Message_AllowStarring')) { | ||
return false; | ||
} | ||
return ChatMessage.update({ | ||
_id: message._id | ||
}, { | ||
$set: { | ||
starred: !!message.starred | ||
} | ||
}); | ||
} | ||
}); |
7 changes: 4 additions & 3 deletions
7
...ketchat-message-star/client/tabBar.coffee → .../rocketchat-message-star/client/tabBar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
Meteor.startup -> | ||
RocketChat.TabBar.addButton({ | ||
Meteor.startup(function() { | ||
return RocketChat.TabBar.addButton({ | ||
groups: ['channel', 'group', 'direct'], | ||
id: 'starred-messages', | ||
i18nTitle: 'Starred_Messages', | ||
icon: 'icon-star', | ||
template: 'starredMessages', | ||
order: 3 | ||
}) | ||
}); | ||
}); |
40 changes: 0 additions & 40 deletions
40
packages/rocketchat-message-star/client/views/starredMessages.coffee
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
packages/rocketchat-message-star/client/views/starredMessages.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/*globals StarredMessage */ | ||
Template.starredMessages.helpers({ | ||
hasMessages() { | ||
return StarredMessage.find({ | ||
rid: this.rid | ||
}, { | ||
sort: { | ||
ts: -1 | ||
} | ||
}).count() > 0; | ||
}, | ||
messages() { | ||
return StarredMessage.find({ | ||
rid: this.rid | ||
}, { | ||
sort: { | ||
ts: -1 | ||
} | ||
}); | ||
}, | ||
message() { | ||
return _.extend(this, { | ||
customClass: 'starred' | ||
}); | ||
}, | ||
hasMore() { | ||
return Template.instance().hasMore.get(); | ||
} | ||
}); | ||
|
||
Template.starredMessages.onCreated(function() { | ||
this.hasMore = new ReactiveVar(true); | ||
this.limit = new ReactiveVar(50); | ||
this.autorun(() => { | ||
const sub = this.subscribe('starredMessages', this.data.rid, this.limit.get()); | ||
const findStarredMessage = StarredMessage.find({ rid: this.data.rid }); | ||
if (sub.ready()) { | ||
if (findStarredMessage.count() < this.limit.get()) { | ||
return this.hasMore.set(false); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
Template.starredMessages.events({ | ||
'click .message-cog'(e, t) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
const message_id = $(e.currentTarget).closest('.message').attr('id'); | ||
RocketChat.MessageAction.hideDropDown(); | ||
t.$(`\#${ message_id } .message-dropdown`).remove(); | ||
const message = StarredMessage.findOne(message_id); | ||
const actions = RocketChat.MessageAction.getButtons(message, 'starred'); | ||
const el = Blaze.toHTMLWithData(Template.messageDropdown, { | ||
actions | ||
}); | ||
t.$(`\#${ message_id } .message-cog-container`).append(el); | ||
const dropDown = t.$(`\#${ message_id } .message-dropdown`); | ||
return dropDown.show(); | ||
}, | ||
'scroll .content': _.throttle(function(e, instance) { | ||
if (e.target.scrollTop >= e.target.scrollHeight - e.target.clientHeight) { | ||
return instance.limit.set(instance.limit.get() + 50); | ||
} | ||
}, 200) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
packages/rocketchat-message-star/server/publications/starredMessages.coffee
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.