-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to sub in "display names" from database when rendering
This also improves the behaviour of mentions in the JS preview (no more broken links, mention is only picked up if corresponding user/post is found). See flarum/framework#1246 Closes flarum/framework#315
- Loading branch information
1 parent
a0d33f8
commit 4aae02b
Showing
7 changed files
with
164 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import username from 'flarum/helpers/username'; | ||
import extractText from 'flarum/utils/extractText'; | ||
|
||
export function filterUserMentions(tag) { | ||
const user = app.store.getBy('users', 'username', tag.getAttribute('username')); | ||
|
||
if (user) { | ||
tag.setAttribute('id', user.id()); | ||
tag.setAttribute('displayname', extractText(username(user))); | ||
|
||
return true; | ||
} | ||
} | ||
|
||
export function filterPostMentions(tag) { | ||
const post = app.store.getById('posts', tag.getAttribute('id')); | ||
|
||
if (post) { | ||
tag.setAttribute('discussionid', post.discussion().id()); | ||
tag.setAttribute('number', post.number()); | ||
tag.setAttribute('displayname', extractText(username(post.user()))); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.