Pass data to url method to avoid duplication

This commit is contained in:
Daniel Waterworth 2019-06-07 10:34:11 +01:00 committed by Robin Ward
parent ac6f7b3625
commit 86d5208b31
3 changed files with 5 additions and 12 deletions

View File

@ -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;

View File

@ -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);
},
});

View File

@ -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