mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 12:17:31 +08:00
Pass data to url method to avoid duplication
This commit is contained in:
parent
ac6f7b3625
commit
86d5208b31
|
@ -28,9 +28,8 @@ export const DefaultNotificationItem =
|
|||
return classNames;
|
||||
},
|
||||
|
||||
url() {
|
||||
url(data) {
|
||||
const attrs = this.attrs;
|
||||
const data = attrs.data;
|
||||
|
||||
const badgeId = data.badge_id;
|
||||
if (badgeId) {
|
||||
|
@ -119,7 +118,7 @@ export const DefaultNotificationItem =
|
|||
|
||||
let contents = [icon, html];
|
||||
|
||||
const href = this.url();
|
||||
const href = this.url(data);
|
||||
return href
|
||||
? h(
|
||||
"a",
|
||||
|
@ -143,7 +142,7 @@ export const DefaultNotificationItem =
|
|||
e.preventDefault();
|
||||
|
||||
this.sendWidgetEvent("linkClicked");
|
||||
DiscourseURL.routeTo(this.url(), {
|
||||
DiscourseURL.routeTo(this.url(this.attrs.data), {
|
||||
afterRouteComplete: () => {
|
||||
if (!this.attrs.data.revision_number) {
|
||||
return;
|
||||
|
|
|
@ -4,10 +4,7 @@ import { postUrl } from "discourse/lib/utilities";
|
|||
import { userPath } from "discourse/lib/url";
|
||||
|
||||
createWidgetFrom(DefaultNotificationItem, "invitee-accepted-notification-item", {
|
||||
url() {
|
||||
const attrs = this.attrs;
|
||||
const data = attrs.data;
|
||||
|
||||
url(data) {
|
||||
return userPath(data.display_username);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,10 +4,7 @@ import { escapeExpression } from "discourse/lib/utilities";
|
|||
import { userPath } from "discourse/lib/url";
|
||||
|
||||
createWidgetFrom(DefaultNotificationItem, "liked-consolidated-notification-item", {
|
||||
url() {
|
||||
const attrs = this.attrs;
|
||||
const data = attrs.data;
|
||||
|
||||
url(data) {
|
||||
return userPath(
|
||||
`${this.attrs.username ||
|
||||
this.currentUser
|
||||
|
|
Loading…
Reference in New Issue
Block a user