Skip to content
Snippets Groups Projects
Commit 182bdbc5 authored by Eugen Rochko's avatar Eugen Rochko Committed by Yamagishi Kazutoshi
Browse files

Don't use Object.assign with Notification, only display actions for mentions (#7632)

Fix #7627
parent 422f92f3
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment