Pull liked notification behaviour in its own class
This commit is contained in:
parent
bd062fcbef
commit
396e13aaa7
|
@ -123,26 +123,6 @@ export const DefaultNotificationItem =
|
||||||
const username = formatUsername(data.display_username);
|
const username = formatUsername(data.display_username);
|
||||||
const description = this.description();
|
const description = this.description();
|
||||||
|
|
||||||
if (notificationType === notificationTypes.liked && data.count > 1) {
|
|
||||||
const count = data.count - 2;
|
|
||||||
const username2 = formatUsername(data.username2);
|
|
||||||
|
|
||||||
if (count === 0) {
|
|
||||||
return I18n.t("notifications.liked_2", {
|
|
||||||
description,
|
|
||||||
username,
|
|
||||||
username2
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return I18n.t("notifications.liked_many", {
|
|
||||||
description,
|
|
||||||
username,
|
|
||||||
username2,
|
|
||||||
count
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return I18n.t(scope, { description, username });
|
return I18n.t(scope, { description, username });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { createWidgetFrom } from "discourse/widgets/widget";
|
||||||
|
import { DefaultNotificationItem } from "discourse/widgets/default-notification-item";
|
||||||
|
import { formatUsername } from "discourse/lib/utilities";
|
||||||
|
|
||||||
|
createWidgetFrom(DefaultNotificationItem, "liked-notification-item", {
|
||||||
|
text(notificationType, notificationName) {
|
||||||
|
const { attrs } = this;
|
||||||
|
const data = attrs.data;
|
||||||
|
|
||||||
|
const username = formatUsername(data.display_username);
|
||||||
|
const description = this.description();
|
||||||
|
|
||||||
|
if (data.count > 1) {
|
||||||
|
const count = data.count - 2;
|
||||||
|
const username2 = formatUsername(data.username2);
|
||||||
|
|
||||||
|
if (count === 0) {
|
||||||
|
return I18n.t("notifications.liked_2", {
|
||||||
|
description,
|
||||||
|
username,
|
||||||
|
username2
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return I18n.t("notifications.liked_many", {
|
||||||
|
description,
|
||||||
|
username,
|
||||||
|
username2,
|
||||||
|
count
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return I18n.t("notifications.liked", { description, username });
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue