mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 08:53:41 +08:00
DEV: Avoid hard-coding notification types integer in client side code.
Co-authored-by: Bianca Nenciu <nenciu.bianca@gmail.com>
This commit is contained in:
parent
0508546fd2
commit
fcb7422213
|
@ -0,0 +1,3 @@
|
||||||
|
<% Notification.types.each do |key, value| %>
|
||||||
|
export const <%= key.upcase %>_TYPE = <%= value %>;
|
||||||
|
<% end %>
|
|
@ -13,10 +13,12 @@ import { setTransientHeader } from "discourse/lib/ajax";
|
||||||
import { userPath } from "discourse/lib/url";
|
import { userPath } from "discourse/lib/url";
|
||||||
import { iconNode } from "discourse-common/lib/icon-library";
|
import { iconNode } from "discourse-common/lib/icon-library";
|
||||||
|
|
||||||
const LIKED_TYPE = 5;
|
import {
|
||||||
const INVITED_TYPE = 8;
|
LIKED_TYPE,
|
||||||
const GROUP_SUMMARY_TYPE = 16;
|
INVITEE_ACCEPTED_TYPE,
|
||||||
export const LIKED_CONSOLIDATED_TYPE = 19;
|
GROUP_MESSAGE_SUMMARY_TYPE,
|
||||||
|
LIKED_CONSOLIDATED_TYPE
|
||||||
|
} from "discourse/widgets/concerns/notification-types";
|
||||||
|
|
||||||
createWidget("notification-item", {
|
createWidget("notification-item", {
|
||||||
tagName: "li",
|
tagName: "li",
|
||||||
|
@ -58,7 +60,7 @@ createWidget("notification-item", {
|
||||||
return postUrl(attrs.slug, topicId, attrs.post_number);
|
return postUrl(attrs.slug, topicId, attrs.post_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrs.notification_type === INVITED_TYPE) {
|
if (attrs.notification_type === INVITEE_ACCEPTED_TYPE) {
|
||||||
return userPath(data.display_username);
|
return userPath(data.display_username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +114,7 @@ createWidget("notification-item", {
|
||||||
const scope =
|
const scope =
|
||||||
notName === "custom" ? data.message : `notifications.${notName}`;
|
notName === "custom" ? data.message : `notifications.${notName}`;
|
||||||
|
|
||||||
if (notificationType === GROUP_SUMMARY_TYPE) {
|
if (notificationType === GROUP_MESSAGE_SUMMARY_TYPE) {
|
||||||
const count = data.inbox_count;
|
const count = data.inbox_count;
|
||||||
const group_name = data.group_name;
|
const group_name = data.group_name;
|
||||||
return I18n.t(scope, { count, group_name });
|
return I18n.t(scope, { count, group_name });
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
/*jshint maxlen:10000000 */
|
/*jshint maxlen:10000000 */
|
||||||
import { LIKED_CONSOLIDATED_TYPE } from "discourse/widgets/notification-item";
|
import {
|
||||||
|
LIKED_CONSOLIDATED_TYPE,
|
||||||
|
REPLIED_TYPE
|
||||||
|
} from "discourse/widgets/concerns/notification-types";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
"/notifications": {
|
"/notifications": {
|
||||||
notifications: [
|
notifications: [
|
||||||
{
|
{
|
||||||
id: 123,
|
id: 123,
|
||||||
notification_type: 2,
|
notification_type: REPLIED_TYPE,
|
||||||
read: false,
|
read: false,
|
||||||
post_number: 2,
|
post_number: 2,
|
||||||
topic_id: 1234,
|
topic_id: 1234,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { LIKED_CONSOLIDATED_TYPE } from "discourse/widgets/notification-item";
|
import { LIKED_CONSOLIDATED_TYPE } from "discourse/widgets/concerns/notification-types";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
"site.json": {
|
"site.json": {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user