mirror of
https://github.com/flarum/core.git
synced 2025-08-03 23:17:43 +02:00
Fix extension to work with latest state changes
Refs flarum/core#2150, flarum/core#2156.
This commit is contained in:
@@ -35,7 +35,7 @@ app.initializers.add('flarum-pusher', () => {
|
|||||||
|
|
||||||
app.pusher.then(channels => {
|
app.pusher.then(channels => {
|
||||||
channels.main.bind('newPost', data => {
|
channels.main.bind('newPost', data => {
|
||||||
const params = this.props.params;
|
const params = app.discussions.getParams();
|
||||||
|
|
||||||
if (!params.q && !params.sort && !params.filter) {
|
if (!params.q && !params.sort && !params.filter) {
|
||||||
if (params.tags) {
|
if (params.tags) {
|
||||||
@@ -46,10 +46,10 @@ app.initializers.add('flarum-pusher', () => {
|
|||||||
|
|
||||||
const id = String(data.discussionId);
|
const id = String(data.discussionId);
|
||||||
|
|
||||||
if ((!app.current.discussion || id !== app.current.discussion.id()) && app.pushedUpdates.indexOf(id) === -1) {
|
if ((!app.current.get('discussion') || id !== app.current.get('discussion').id()) && app.pushedUpdates.indexOf(id) === -1) {
|
||||||
app.pushedUpdates.push(id);
|
app.pushedUpdates.push(id);
|
||||||
|
|
||||||
if (app.current instanceof IndexPage) {
|
if (app.current.matches(IndexPage)) {
|
||||||
app.setTitleCount(app.pushedUpdates.length);
|
app.setTitleCount(app.pushedUpdates.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ app.initializers.add('flarum-pusher', () => {
|
|||||||
app.pushedUpdates.splice(index, 1);
|
app.pushedUpdates.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.current instanceof IndexPage) {
|
if (app.current.matches(IndexPage)) {
|
||||||
app.setTitleCount(app.pushedUpdates.length);
|
app.setTitleCount(app.pushedUpdates.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ app.initializers.add('flarum-pusher', () => {
|
|||||||
unreadNotificationCount: app.session.user.unreadNotificationCount() + 1,
|
unreadNotificationCount: app.session.user.unreadNotificationCount() + 1,
|
||||||
newNotificationCount: app.session.user.newNotificationCount() + 1
|
newNotificationCount: app.session.user.newNotificationCount() + 1
|
||||||
});
|
});
|
||||||
delete app.cache.notifications;
|
app.notifications.clear();
|
||||||
m.redraw();
|
m.redraw();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user