Skip to content

Commit

Permalink
error handling, error toasts
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-rajpal committed Aug 17, 2022
1 parent c55d8d1 commit 8fcdccc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
12 changes: 8 additions & 4 deletions apps/meteor/app/message-pin/client/actionButton.ts
Expand Up @@ -106,10 +106,14 @@ Meteor.startup(function () {
// classes: 'clipboard',
context: ['pinned'],
async action(_, props) {
const { message = messageArgs(this).msg } = props;
const permalink = await MessageAction.getPermaLink(message._id);
navigator.clipboard.writeText(permalink);
dispatchToastMessage({ type: 'success', message: TAPi18n.__('Copied') });
try {
const { message = messageArgs(this).msg } = props;
const permalink = await MessageAction.getPermaLink(message._id);
navigator.clipboard.writeText(permalink);
dispatchToastMessage({ type: 'success', message: TAPi18n.__('Copied') });
} catch (e) {
dispatchToastMessage({ type: 'error', message: e });
}
},
condition({ subscription }) {
return !!subscription;
Expand Down
12 changes: 8 additions & 4 deletions apps/meteor/app/message-star/client/actionButton.ts
Expand Up @@ -110,10 +110,14 @@ Meteor.startup(function () {
// classes: 'clipboard',
context: ['starred', 'threads'],
async action(_, props) {
const { message = messageArgs(this).msg } = props;
const permalink = await MessageAction.getPermaLink(message._id);
navigator.clipboard.writeText(permalink);
dispatchToastMessage({ type: 'success', message: TAPi18n.__('Copied') });
try {
const { message = messageArgs(this).msg } = props;
const permalink = await MessageAction.getPermaLink(message._id);
navigator.clipboard.writeText(permalink);
dispatchToastMessage({ type: 'success', message: TAPi18n.__('Copied') });
} catch (e) {
dispatchToastMessage({ type: 'error', message: e });
}
},
condition({ message, subscription, user }) {
if (subscription == null) {
Expand Down
12 changes: 8 additions & 4 deletions apps/meteor/app/ui-utils/client/lib/messageActionDefault.ts
Expand Up @@ -112,10 +112,14 @@ Meteor.startup(async function () {
// classes: 'clipboard',
context: ['message', 'message-mobile', 'threads', 'federated'],
async action(_, props) {
const { message = messageArgs(this).msg } = props;
const permalink = await MessageAction.getPermaLink(message._id);
navigator.clipboard.writeText(permalink);
dispatchToastMessage({ type: 'success', message: TAPi18n.__('Copied') });
try {
const { message = messageArgs(this).msg } = props;
const permalink = await MessageAction.getPermaLink(message._id);
navigator.clipboard.writeText(permalink);
dispatchToastMessage({ type: 'success', message: TAPi18n.__('Copied') });
} catch (e) {
dispatchToastMessage({ type: 'error', message: e });
}
},
condition({ subscription }) {
return !!subscription;
Expand Down

0 comments on commit 8fcdccc

Please sign in to comment.