Skip to content
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

[IMPROVE] User gets UI feedback when message is pinned or unpinned #16056

Merged
merged 5 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/message-pin/client/pinMessage.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import { Meteor } from 'meteor/meteor';
import toastr from 'toastr';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';

import { settings } from '../../settings';
import { ChatMessage, Subscriptions } from '../../models';

Meteor.methods({
pinMessage(message) {
if (!Meteor.userId()) {
toastr.error(TAPi18n.__('error-not-authorized'));
return false;
}
if (!settings.get('Message_AllowPinning')) {
toastr.error(TAPi18n.__('pinning-not-allowed'));
return false;
}
if (Subscriptions.findOne({ rid: message.rid }) == null) {
toastr.error(TAPi18n.__('error-pinning-message'));
return false;
}
toastr.success(TAPi18n.__('Message_has_been_pinned'));
return ChatMessage.update({
_id: message._id,
}, {
Expand All @@ -24,14 +30,18 @@ Meteor.methods({
},
unpinMessage(message) {
if (!Meteor.userId()) {
toastr.error(TAPi18n.__('error-not-authorized'));
return false;
}
if (!settings.get('Message_AllowPinning')) {
toastr.error(TAPi18n.__('unpinning-not-allowed'));
return false;
}
if (Subscriptions.findOne({ rid: message.rid }) == null) {
toastr.error(TAPi18n.__('error-unpinning-message'));
return false;
}
toastr.success(TAPi18n.__('Message_has_been_unpinned'));
return ChatMessage.update({
_id: message._id,
}, {
Expand Down
6 changes: 6 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,8 @@
"error-password-policy-not-met-oneSpecial": "Password does not meet the server's policy of at least one special character",
"error-password-policy-not-met-oneUppercase": "Password does not meet the server's policy of at least one uppercase character",
"error-password-policy-not-met-repeatingCharacters": "Password not not meet the server's policy of forbidden repeating characters (you have too many of the same characters next to each other)",
"error-pinning-message": "Message could not be pinned",
"error-unpinning-message": "Message could not be unpinned",
"error-push-disabled": "Push is disabled",
"error-remove-last-owner": "This is the last owner. Please set a new owner before removing this one.",
"error-tags-must-be-assigned-before-closing-chat": "Tag(s) must be assigned before closing the chat",
Expand Down Expand Up @@ -2328,6 +2330,8 @@
"Message_GlobalSearch": "Global Search",
"Message_GroupingPeriod": "Grouping Period (in seconds)",
"Message_GroupingPeriodDescription": "Messages will be grouped with previous message if both are from the same user and the elapsed time was less than the informed time in seconds.",
"Message_has_been_pinned": "Message has been pinned",
"Message_has_been_unpinned": "Message has been unpinned",
"Message_has_been_starred": "Message has been starred",
"Message_has_been_unstarred": "Message has been unstarred",
"Message_HideType_au": "Hide \"User Added\" messages",
Expand Down Expand Up @@ -2627,6 +2631,7 @@
"Pin_Message": "Pin Message",
"Pinned_a_message": "Pinned a message:",
"Pinned_Messages": "Pinned Messages",
"pinning-not-allowed": "Pinning is not allowed",
"PiwikAdditionalTrackers": "Additional Piwik Sites",
"PiwikAdditionalTrackers_Description": "Enter addtitional Piwik website URLs and SiteIDs in the following format, if you wnat to track the same data into different websites: [ { \"trackerURL\" : \"https://my.piwik.domain2/\", \"siteId\" : 42 }, { \"trackerURL\" : \"https://my.piwik.domain3/\", \"siteId\" : 15 } ]",
"PiwikAnalytics_cookieDomain": "All Subdomains",
Expand Down Expand Up @@ -3450,6 +3455,7 @@
"Unnamed": "Unnamed",
"Unpin": "Unpin",
"Unpin_Message": "Unpin Message",
"unpinning-not-allowed": "Unpinning is not allowed",
"Unread": "Unread",
"Unread_Count": "Unread Count",
"Unread_Count_DM": "Unread Count for Direct Messages",
Expand Down