mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-24 03:43:42 +01:00
Don't use Object.assign with Notification, only display actions for mentions (#7632)
Fix #7627
This commit is contained in:
parent
422f92f3f8
commit
182bdbc5f4
1 changed files with 16 additions and 4 deletions
|
@ -25,7 +25,7 @@ const notify = options =>
|
|||
|
||||
return self.registration.showNotification(group.title, group);
|
||||
} else if (notifications.length === 1 && notifications[0].tag === GROUP_TAG) { // Already grouped, proceed with appending the notification to the group
|
||||
const group = { ...notifications[0] };
|
||||
const group = cloneNotification(notifications[0]);
|
||||
|
||||
group.title = formatMessage('notifications.group', options.data.preferred_locale, { count: group.data.count + 1 });
|
||||
group.body = `${options.title}\n${group.body}`;
|
||||
|
@ -57,6 +57,18 @@ const fetchFromApi = (path, method, accessToken) => {
|
|||
}).then(res => res.json());
|
||||
};
|
||||
|
||||
const cloneNotification = notification => {
|
||||
const clone = {};
|
||||
let k;
|
||||
|
||||
// Object.assign() does not work with notifications
|
||||
for(k in notification) {
|
||||
clone[k] = notification[k];
|
||||
}
|
||||
|
||||
return clone;
|
||||
};
|
||||
|
||||
const formatMessage = (messageId, locale, values = {}) =>
|
||||
(new IntlMessageFormat(locales[locale][messageId], locale)).format(values);
|
||||
|
||||
|
@ -95,7 +107,7 @@ const handlePush = (event) => {
|
|||
options.body = notification.status.spoiler_text;
|
||||
options.image = undefined;
|
||||
options.actions = [actionExpand(preferred_locale)];
|
||||
} else if (notification.status) {
|
||||
} else if (notification.type === 'mention') {
|
||||
options.actions = [actionReblog(preferred_locale), actionFavourite(preferred_locale)];
|
||||
}
|
||||
|
||||
|
@ -130,7 +142,7 @@ const findBestClient = clients => {
|
|||
};
|
||||
|
||||
const expandNotification = notification => {
|
||||
const newNotification = { ...notification };
|
||||
const newNotification = cloneNotification(notification);
|
||||
|
||||
newNotification.body = newNotification.data.hiddenBody;
|
||||
newNotification.image = newNotification.data.hiddenImage;
|
||||
|
@ -140,7 +152,7 @@ const expandNotification = notification => {
|
|||
};
|
||||
|
||||
const removeActionFromNotification = (notification, action) => {
|
||||
const newNotification = { ...notification };
|
||||
const newNotification = cloneNotification(notification);
|
||||
|
||||
newNotification.actions = newNotification.actions.filter(item => item.action !== action);
|
||||
|
||||
|
|
Loading…
Reference in a new issue