-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Convert Mentions-Flextab Package to Js #6689
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Remove the package
coffeescript