diff --git a/js/src/forum/addMentionedByList.js b/js/src/forum/addMentionedByList.js index 63e02de..7376218 100644 --- a/js/src/forum/addMentionedByList.js +++ b/js/src/forum/addMentionedByList.js @@ -1,7 +1,5 @@ import app from 'flarum/forum/app'; import { extend } from 'flarum/common/extend'; -import Model from 'flarum/common/Model'; -import Post from 'flarum/common/models/Post'; import CommentPost from 'flarum/forum/components/CommentPost'; import Link from 'flarum/common/components/Link'; import PostPreview from 'flarum/forum/components/PostPreview'; @@ -10,8 +8,6 @@ import username from 'flarum/common/helpers/username'; import icon from 'flarum/common/helpers/icon'; export default function addMentionedByList() { - Post.prototype.mentionedBy = Model.hasMany('mentionedBy'); - function hidePreview() { this.$('.Post-mentionedBy-preview') .removeClass('in') diff --git a/js/src/forum/extend.ts b/js/src/forum/extend.ts index d860db4..d98a961 100644 --- a/js/src/forum/extend.ts +++ b/js/src/forum/extend.ts @@ -1,4 +1,15 @@ import Extend from 'flarum/common/extenders'; +import Post from 'flarum/common/models/Post'; +import User from 'flarum/common/models/User'; import MentionsUserPage from './components/MentionsUserPage'; -export default [new Extend.Routes().add('user.mentions', '/u/:username/mentions', MentionsUserPage)]; +export default [ + new Extend.Routes() // + .add('user.mentions', '/u/:username/mentions', MentionsUserPage), + + new Extend.Model(Post) // + .hasMany('mentionedBy'), + + new Extend.Model(User) // + .attribute('canMentionGroups'), +]; diff --git a/js/src/forum/index.js b/js/src/forum/index.js index 96c9cae..40910b6 100644 --- a/js/src/forum/index.js +++ b/js/src/forum/index.js @@ -21,8 +21,6 @@ import Model from 'flarum/common/Model'; export { default as extend } from './extend'; app.initializers.add('flarum-mentions', function () { - User.prototype.canMentionGroups = Model.attribute('canMentionGroups'); - // For every mention of a post inside a post's content, set up a hover handler // that shows a preview of the mentioned post. addPostMentionPreviews();