mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:54:59 +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 { iconNode } from "discourse-common/lib/icon-library";
|
||||
|
||||
const LIKED_TYPE = 5;
|
||||
const INVITED_TYPE = 8;
|
||||
const GROUP_SUMMARY_TYPE = 16;
|
||||
export const LIKED_CONSOLIDATED_TYPE = 19;
|
||||
import {
|
||||
LIKED_TYPE,
|
||||
INVITEE_ACCEPTED_TYPE,
|
||||
GROUP_MESSAGE_SUMMARY_TYPE,
|
||||
LIKED_CONSOLIDATED_TYPE
|
||||
} from "discourse/widgets/concerns/notification-types";
|
||||
|
||||
createWidget("notification-item", {
|
||||
tagName: "li",
|
||||
|
@ -58,7 +60,7 @@ createWidget("notification-item", {
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -112,7 +114,7 @@ createWidget("notification-item", {
|
|||
const scope =
|
||||
notName === "custom" ? data.message : `notifications.${notName}`;
|
||||
|
||||
if (notificationType === GROUP_SUMMARY_TYPE) {
|
||||
if (notificationType === GROUP_MESSAGE_SUMMARY_TYPE) {
|
||||
const count = data.inbox_count;
|
||||
const group_name = data.group_name;
|
||||
return I18n.t(scope, { count, group_name });
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
/*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 {
|
||||
"/notifications": {
|
||||
notifications: [
|
||||
{
|
||||
id: 123,
|
||||
notification_type: 2,
|
||||
notification_type: REPLIED_TYPE,
|
||||
read: false,
|
||||
post_number: 2,
|
||||
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 {
|
||||
"site.json": {
|
||||
|
|
Loading…
Reference in New Issue
Block a user