-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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 #6689 from RocketChat/mentions-to-js
Convert Mentions-Flextab Package to Js
- Loading branch information
Showing
10 changed files
with
124 additions
and
91 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
packages/rocketchat-mentions-flextab/client/actionButton.coffee
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
packages/rocketchat-mentions-flextab/client/actionButton.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,17 @@ | ||
Meteor.startup(function() { | ||
return RocketChat.MessageAction.addButton({ | ||
id: 'jump-to-message', | ||
icon: 'icon-right-hand', | ||
i18nLabel: 'Jump_to_message', | ||
context: ['mentions'], | ||
action() { | ||
const message = this._arguments[1]; | ||
RocketChat.MessageAction.hideDropDown(); | ||
return RoomHistoryManager.getSurroundingMessages(message, 50); | ||
}, | ||
validation(message) { | ||
return message.mentionedList === true; | ||
}, | ||
order: 100 | ||
}); | ||
}); |
1 change: 0 additions & 1 deletion
1
packages/rocketchat-mentions-flextab/client/lib/MentionedMessage.coffee
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/rocketchat-mentions-flextab/client/lib/MentionedMessage.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 @@ | ||
this.MentionedMessage = new Mongo.Collection('rocketchat_mentioned_message'); |
7 changes: 4 additions & 3 deletions
7
...hat-mentions-flextab/client/tabBar.coffee → ...ketchat-mentions-flextab/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'], | ||
id: 'mentions', | ||
i18nTitle: 'Mentions', | ||
icon: 'icon-at', | ||
template: 'mentionsFlexTab', | ||
order: 3 | ||
}) | ||
}); | ||
}); |
39 changes: 0 additions & 39 deletions
39
packages/rocketchat-mentions-flextab/client/views/mentionsFlexTab.coffee
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
packages/rocketchat-mentions-flextab/client/views/mentionsFlexTab.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,65 @@ | ||
/*globals MentionedMessage */ | ||
Template.mentionsFlexTab.helpers({ | ||
hasMessages() { | ||
return MentionedMessage.find({ | ||
rid: this.rid | ||
}, { | ||
sort: { | ||
ts: -1 | ||
} | ||
}).count() > 0; | ||
}, | ||
messages() { | ||
return MentionedMessage.find({ | ||
rid: this.rid | ||
}, { | ||
sort: { | ||
ts: -1 | ||
} | ||
}); | ||
}, | ||
message() { | ||
return _.extend(this, { | ||
customClass: 'mentions' | ||
}); | ||
}, | ||
hasMore() { | ||
return Template.instance().hasMore.get(); | ||
} | ||
}); | ||
|
||
Template.mentionsFlexTab.onCreated(function() { | ||
this.hasMore = new ReactiveVar(true); | ||
this.limit = new ReactiveVar(50); | ||
return this.autorun(() => { | ||
const mentionedMessageFind = MentionedMessage.find({ rid: this.data.rid }); | ||
return this.subscribe('mentionedMessages', this.data.rid, this.limit.get(), () => { | ||
if (mentionedMessageFind.count() < this.limit.get()) { | ||
return this.hasMore.set(false); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
Template.mentionsFlexTab.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 = MentionedMessage.findOne(message_id); | ||
const actions = RocketChat.MessageAction.getButtons(message, 'mentions'); | ||
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 && instance.hasMore.get()) { | ||
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
25 changes: 0 additions & 25 deletions
25
packages/rocketchat-mentions-flextab/server/publications/mentionedMessages.coffee
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
packages/rocketchat-mentions-flextab/server/publications/mentionedMessages.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,32 @@ | ||
Meteor.publish('mentionedMessages', function(rid, limit = 50) { | ||
if (!this.userId) { | ||
return this.ready(); | ||
} | ||
const publication = this; | ||
const user = RocketChat.models.Users.findOneById(this.userId); | ||
if (!user) { | ||
return this.ready(); | ||
} | ||
const cursorHandle = RocketChat.models.Messages.findVisibleByMentionAndRoomId(user.username, rid, { | ||
sort: { | ||
ts: -1 | ||
}, | ||
limit | ||
}).observeChanges({ | ||
added(_id, record) { | ||
record.mentionedList = true; | ||
return publication.added('rocketchat_mentioned_message', _id, record); | ||
}, | ||
changed(_id, record) { | ||
record.mentionedList = true; | ||
return publication.changed('rocketchat_mentioned_message', _id, record); | ||
}, | ||
removed(_id) { | ||
return publication.removed('rocketchat_mentioned_message', _id); | ||
} | ||
}); | ||
this.ready(); | ||
return this.onStop(function() { | ||
return cursorHandle.stop(); | ||
}); | ||
}); |