From 592dd6a9275fb8213ca06a777cd836ca2c064258 Mon Sep 17 00:00:00 2001 From: David Sevilla Martin Date: Tue, 30 Aug 2016 10:35:31 -0400 Subject: [PATCH] Fixed error when user is not logged in; fixed notification count not updating when clicking home link (added m.redraw) --- js/forum/dist/app.js | 11 ++++++++--- js/forum/src/components/IndexPage.js | 6 ++++-- js/forum/src/initializers/boot.js | 5 ++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/js/forum/dist/app.js b/js/forum/dist/app.js index 28d6e2eb5..41f088a7c 100644 --- a/js/forum/dist/app.js +++ b/js/forum/dist/app.js @@ -22689,8 +22689,10 @@ System.register('flarum/components/IndexPage', ['flarum/extend', 'flarum/compone className: 'Button Button--icon', onclick: function onclick() { app.cache.discussionList.refresh(); - app.store.find('users', app.session.user.id()); - m.redraw(); + if (app.session.user) { + app.store.find('users', app.session.user.id()); + m.redraw(); + } } })); @@ -28730,8 +28732,11 @@ System.register('flarum/initializers/boot', ['flarum/utils/ScrollListener', 'fla $('#home-link').click(function (e) { if (e.ctrlKey || e.metaKey || e.which === 2) return; e.preventDefault(); - app.store.find('users', app.session.user.id()); app.history.home(); + if (app.session.user) { + app.store.find('users', app.session.user.id()); + m.redraw(); + } }); // Add a class to the body which indicates that the page has been scrolled diff --git a/js/forum/src/components/IndexPage.js b/js/forum/src/components/IndexPage.js index 35a8178ea..6c3bbb9e4 100644 --- a/js/forum/src/components/IndexPage.js +++ b/js/forum/src/components/IndexPage.js @@ -238,8 +238,10 @@ export default class IndexPage extends Page { className: 'Button Button--icon', onclick: () => { app.cache.discussionList.refresh(); - app.store.find('users', app.session.user.id()); - m.redraw(); + if (app.session.user) { + app.store.find('users', app.session.user.id()); + m.redraw(); + } } }) ); diff --git a/js/forum/src/initializers/boot.js b/js/forum/src/initializers/boot.js index 827109a3e..c5b3e9bfc 100644 --- a/js/forum/src/initializers/boot.js +++ b/js/forum/src/initializers/boot.js @@ -61,8 +61,11 @@ export default function boot(app) { $('#home-link').click(e => { if (e.ctrlKey || e.metaKey || e.which === 2) return; e.preventDefault(); - app.store.find('users', app.session.user.id()); app.history.home(); + if (app.session.user) { + app.store.find('users', app.session.user.id()); + m.redraw(); + } }); // Add a class to the body which indicates that the page has been scrolled