diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index aace6f8e0..7dbce6dbb 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -725,7 +725,8 @@ export default ObjectController.extend(SelectedPostsCount, BufferedContent, { }, _showFooter: function() { - this.set("controllers.application.showFooter", this.get("model.postStream.loadedAllPosts")); - }.observes("model.postStream.loadedAllPosts") + const showFooter = this.get("model.postStream.loaded") && this.get("model.postStream.loadedAllPosts"); + this.set("controllers.application.showFooter", showFooter); + }.observes("model.postStream.{loaded,loadedAllPosts}") }); diff --git a/app/assets/javascripts/discourse/initializers/show-footer.js.es6 b/app/assets/javascripts/discourse/initializers/show-footer.js.es6 new file mode 100644 index 000000000..ce5845777 --- /dev/null +++ b/app/assets/javascripts/discourse/initializers/show-footer.js.es6 @@ -0,0 +1,15 @@ +export default { + name: "show-footer", + + initialize(container) { + const router = container.lookup("router:main"); + const application = container.lookup("controller:application"); + + // only take care of hiding the footer here + // controllers MUST take care of displaying it + router.on("willTransition", () => { + application.set("showFooter", false); + return true; + }); + } +}; diff --git a/app/assets/javascripts/discourse/lib/static-route-builder.js.es6 b/app/assets/javascripts/discourse/lib/static-route-builder.js.es6 index 79365f465..a1140f89a 100644 --- a/app/assets/javascripts/discourse/lib/static-route-builder.js.es6 +++ b/app/assets/javascripts/discourse/lib/static-route-builder.js.es6 @@ -1,5 +1,3 @@ -import ShowFooter from "discourse/mixins/show-footer"; - var configs = { 'faq': 'faq_url', 'tos': 'tos_url', @@ -7,7 +5,7 @@ var configs = { }; export default function(page) { - return Discourse.Route.extend(ShowFooter, { + return Discourse.Route.extend({ renderTemplate: function() { this.render('static'); }, diff --git a/app/assets/javascripts/discourse/mixins/show-footer.js.es6 b/app/assets/javascripts/discourse/mixins/show-footer.js.es6 deleted file mode 100644 index b97014153..000000000 --- a/app/assets/javascripts/discourse/mixins/show-footer.js.es6 +++ /dev/null @@ -1,15 +0,0 @@ -export default Em.Mixin.create({ - actions: { - didTransition() { - Em.run.schedule("afterRender", () => { - this.controllerFor("application").set("showFooter", true); - }); - return true; - }, - - willTransition() { - this.controllerFor("application").set("showFooter", false); - return true; - } - } -}); diff --git a/app/assets/javascripts/discourse/routes/about.js.es6 b/app/assets/javascripts/discourse/routes/about.js.es6 index 5258ea7fb..3021dd083 100644 --- a/app/assets/javascripts/discourse/routes/about.js.es6 +++ b/app/assets/javascripts/discourse/routes/about.js.es6 @@ -1,6 +1,4 @@ -import ShowFooter from "discourse/mixins/show-footer"; - -export default Discourse.Route.extend(ShowFooter, { +export default Discourse.Route.extend({ model: function() { return Discourse.ajax("/about.json").then(function(result) { return result.about; diff --git a/app/assets/javascripts/discourse/routes/badges-index.js.es6 b/app/assets/javascripts/discourse/routes/badges-index.js.es6 index 67af4625f..fb7e99056 100644 --- a/app/assets/javascripts/discourse/routes/badges-index.js.es6 +++ b/app/assets/javascripts/discourse/routes/badges-index.js.es6 @@ -1,6 +1,4 @@ -import ShowFooter from "discourse/mixins/show-footer"; - -export default Discourse.Route.extend(ShowFooter, { +export default Discourse.Route.extend({ model: function() { if (PreloadStore.get('badges')) { return PreloadStore.getAndRemove('badges').then(function(json) { diff --git a/app/assets/javascripts/discourse/routes/badges-show.js.es6 b/app/assets/javascripts/discourse/routes/badges-show.js.es6 index 7b897f03b..7cbb37c01 100644 --- a/app/assets/javascripts/discourse/routes/badges-show.js.es6 +++ b/app/assets/javascripts/discourse/routes/badges-show.js.es6 @@ -1,6 +1,4 @@ -import ShowFooter from "discourse/mixins/show-footer"; - -export default Discourse.Route.extend(ShowFooter, { +export default Discourse.Route.extend({ actions: { didTransition: function() { this.controllerFor("badges/show")._showFooter(); diff --git a/app/assets/javascripts/discourse/routes/build-admin-user-posts-route.js.es6 b/app/assets/javascripts/discourse/routes/build-admin-user-posts-route.js.es6 index 6d79b3b48..1615cdaca 100644 --- a/app/assets/javascripts/discourse/routes/build-admin-user-posts-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-admin-user-posts-route.js.es6 @@ -1,31 +1,29 @@ -import ShowFooter from "discourse/mixins/show-footer"; - export default function (filter) { - return Discourse.Route.extend(ShowFooter, { + return Discourse.Route.extend({ actions: { - didTransition: function() { - this.controllerFor('user').set('indexStream', true); + didTransition() { + this.controllerFor("user").set("indexStream", true); this.controllerFor("user-posts")._showFooter(); return true; } }, - model: function () { + model() { return this.modelFor("user").get("postsStream"); }, - afterModel: function () { + afterModel() { return this.modelFor("user").get("postsStream").filterBy(filter); }, - setupController: function(controller, model) { + setupController(controller, model) { // initialize "canLoadMore" model.set("canLoadMore", model.get("itemsLoaded") === 60); this.controllerFor("user-posts").set("model", model); }, - renderTemplate: function() { + renderTemplate() { this.render("user/posts", { into: "user" }); } }); diff --git a/app/assets/javascripts/discourse/routes/build-user-topic-list-route.js.es6 b/app/assets/javascripts/discourse/routes/build-user-topic-list-route.js.es6 index b5a83808d..c14174fae 100644 --- a/app/assets/javascripts/discourse/routes/build-user-topic-list-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-user-topic-list-route.js.es6 @@ -1,36 +1,35 @@ import UserTopicListRoute from "discourse/routes/user-topic-list"; -import ShowFooter from "discourse/mixins/show-footer"; // A helper to build a user topic list route -export default function (viewName, path) { - return UserTopicListRoute.extend(ShowFooter, { +export default (viewName, path) => { + return UserTopicListRoute.extend({ userActionType: Discourse.UserAction.TYPES.messages_received, actions: { - didTransition: function() { + didTransition() { this.controllerFor("user-topics-list")._showFooter(); return true; } }, - model: function() { - return this.store.findFiltered('topicList', {filter: 'topics/' + path + '/' + this.modelFor('user').get('username_lower')}); + model() { + return this.store.findFiltered("topicList", { filter: "topics/" + path + "/" + this.modelFor("user").get("username_lower") }); }, - setupController: function() { + setupController() { this._super.apply(this, arguments); - this.controllerFor('user-topics-list').setProperties({ + this.controllerFor("user-topics-list").setProperties({ hideCategory: true, showParticipants: true }); - this.controllerFor('user').set('pmView', viewName); - this.controllerFor('search').set('contextType', 'private_messages'); + this.controllerFor("user").set("pmView", viewName); + this.controllerFor("search").set("contextType", "private_messages"); }, - deactivate: function(){ - this.controllerFor('search').set('contextType', 'user'); + deactivate() { + this.controllerFor("search").set("contextType", "user"); } }); -} +}; diff --git a/app/assets/javascripts/discourse/routes/discovery-categories-route.js.es6 b/app/assets/javascripts/discourse/routes/discovery-categories-route.js.es6 index c46b9b827..2ac037c48 100644 --- a/app/assets/javascripts/discourse/routes/discovery-categories-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/discovery-categories-route.js.es6 @@ -1,8 +1,7 @@ -import ShowFooter from 'discourse/mixins/show-footer'; import showModal from 'discourse/lib/show-modal'; import OpenComposer from "discourse/mixins/open-composer"; -Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(OpenComposer, ShowFooter, { +Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(OpenComposer, { renderTemplate() { this.render('navigation/categories', { outlet: 'navigation-bar' }); this.render('discovery/categories', { outlet: 'list-container' }); diff --git a/app/assets/javascripts/discourse/routes/discovery.js.es6 b/app/assets/javascripts/discourse/routes/discovery.js.es6 index e5be7da1e..eb8abb275 100644 --- a/app/assets/javascripts/discourse/routes/discovery.js.es6 +++ b/app/assets/javascripts/discourse/routes/discovery.js.es6 @@ -2,14 +2,15 @@ The parent route for all discovery routes. Handles the logic for showing the loading spinners. **/ -import ShowFooter from "discourse/mixins/show-footer"; import OpenComposer from "discourse/mixins/open-composer"; import { scrollTop } from 'discourse/mixins/scroll-top'; -const DiscoveryRoute = Discourse.Route.extend(OpenComposer, ShowFooter, { - redirect: function() { return this.redirectIfLoginRequired(); }, +const DiscoveryRoute = Discourse.Route.extend(OpenComposer, { + redirect() { + return this.redirectIfLoginRequired(); + }, - beforeModel: function(transition) { + beforeModel(transition) { if (transition.intent.url === "/" && transition.targetName.indexOf("discovery.top") === -1 && Discourse.User.currentProp("should_be_redirected_to_top")) { @@ -19,30 +20,30 @@ const DiscoveryRoute = Discourse.Route.extend(OpenComposer, ShowFooter, { }, actions: { - loading: function() { + loading() { this.controllerFor('discovery').set("loading", true); return true; }, - loadingComplete: function() { + loadingComplete() { this.controllerFor('discovery').set('loading', false); if (!this.session.get('topicListScrollPosition')) { scrollTop(); } }, - didTransition: function() { + didTransition() { this.controllerFor("discovery")._showFooter(); this.send('loadingComplete'); return true; }, // clear a pinned topic - clearPin: function(topic) { + clearPin(topic) { topic.clearPin(); }, - createTopic: function() { + createTopic() { this.openComposer(this.controllerFor('discovery/topics')); } } diff --git a/app/assets/javascripts/discourse/routes/exception.js.es6 b/app/assets/javascripts/discourse/routes/exception.js.es6 index a5c5fab87..d20795d02 100644 --- a/app/assets/javascripts/discourse/routes/exception.js.es6 +++ b/app/assets/javascripts/discourse/routes/exception.js.es6 @@ -1,7 +1,3 @@ -import ShowFooter from "discourse/mixins/show-footer"; - -export default Discourse.Route.extend(ShowFooter, { - serialize: function() { - return ""; - } +export default Discourse.Route.extend({ + serialize() { return ""; } }); diff --git a/app/assets/javascripts/discourse/routes/group-index.js.es6 b/app/assets/javascripts/discourse/routes/group-index.js.es6 index 63a1a23f7..89dec1edd 100644 --- a/app/assets/javascripts/discourse/routes/group-index.js.es6 +++ b/app/assets/javascripts/discourse/routes/group-index.js.es6 @@ -1,18 +1,14 @@ -import ShowFooter from "discourse/mixins/show-footer"; - -export default Discourse.Route.extend(ShowFooter, { +export default Discourse.Route.extend({ actions: { - didTransition: function() { - return true; - } + didTransition() { return true; } }, - model: function() { - return this.modelFor('group').findPosts(); + model() { + return this.modelFor("group").findPosts(); }, - setupController: function(controller, model) { - controller.set('model', model); - this.controllerFor('group').set('showing', 'index'); + setupController(controller, model) { + controller.set("model", model); + this.controllerFor("group").set("showing", "index"); } }); diff --git a/app/assets/javascripts/discourse/routes/group-members.js.es6 b/app/assets/javascripts/discourse/routes/group-members.js.es6 index 4713495d8..22e328cac 100644 --- a/app/assets/javascripts/discourse/routes/group-members.js.es6 +++ b/app/assets/javascripts/discourse/routes/group-members.js.es6 @@ -1,12 +1,10 @@ -import ShowFooter from "discourse/mixins/show-footer"; - -export default Discourse.Route.extend(ShowFooter, { +export default Discourse.Route.extend({ model() { - return this.modelFor('group'); + return this.modelFor("group"); }, setupController(controller, model) { - this.controllerFor('group').set('showing', 'members'); + this.controllerFor("group").set("showing", "members"); controller.set("model", model); model.findMembers(); } diff --git a/app/assets/javascripts/discourse/routes/preferences.js.es6 b/app/assets/javascripts/discourse/routes/preferences.js.es6 index 67fd1b923..d748689f4 100644 --- a/app/assets/javascripts/discourse/routes/preferences.js.es6 +++ b/app/assets/javascripts/discourse/routes/preferences.js.es6 @@ -1,8 +1,7 @@ -import ShowFooter from "discourse/mixins/show-footer"; import RestrictedUserRoute from "discourse/routes/restricted-user"; import showModal from 'discourse/lib/show-modal'; -export default RestrictedUserRoute.extend(ShowFooter, { +export default RestrictedUserRoute.extend({ model() { return this.modelFor('user'); }, diff --git a/app/assets/javascripts/discourse/routes/topic.js.es6 b/app/assets/javascripts/discourse/routes/topic.js.es6 index 63762c7b5..7d5f25334 100644 --- a/app/assets/javascripts/discourse/routes/topic.js.es6 +++ b/app/assets/javascripts/discourse/routes/topic.js.es6 @@ -4,10 +4,9 @@ let isTransitioning = false, const SCROLL_DELAY = 500; -import ShowFooter from "discourse/mixins/show-footer"; import showModal from 'discourse/lib/show-modal'; -const TopicRoute = Discourse.Route.extend(ShowFooter, { +const TopicRoute = Discourse.Route.extend({ redirect() { return this.redirectIfLoginRequired(); }, queryParams: { diff --git a/app/assets/javascripts/discourse/routes/user-activity-stream.js.es6 b/app/assets/javascripts/discourse/routes/user-activity-stream.js.es6 index bec825f84..e77b58da1 100644 --- a/app/assets/javascripts/discourse/routes/user-activity-stream.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-activity-stream.js.es6 @@ -1,32 +1,31 @@ -import ShowFooter from "discourse/mixins/show-footer"; import ViewingActionType from "discourse/mixins/viewing-action-type"; -export default Discourse.Route.extend(ShowFooter, ViewingActionType, { - model: function() { +export default Discourse.Route.extend(ViewingActionType, { + model() { return this.modelFor('user').get('stream'); }, - afterModel: function() { + afterModel() { return this.modelFor('user').get('stream').filterBy(this.get('userActionType')); }, - renderTemplate: function() { + renderTemplate() { this.render('user_stream'); }, - setupController: function(controller, model) { + setupController(controller, model) { controller.set('model', model); this.viewingActionType(this.get('userActionType')); }, actions: { - didTransition: function() { + didTransition() { this.controllerFor("user-activity")._showFooter(); return true; }, - removeBookmark: function(userAction) { + removeBookmark(userAction) { var user = this.modelFor('user'); Discourse.Post.updateBookmark(userAction.get('post_id'), false) .then(function() { diff --git a/app/assets/javascripts/discourse/routes/user-badges.js.es6 b/app/assets/javascripts/discourse/routes/user-badges.js.es6 index d3b39a3b9..9594cc73b 100644 --- a/app/assets/javascripts/discourse/routes/user-badges.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-badges.js.es6 @@ -1,17 +1,16 @@ -import ShowFooter from "discourse/mixins/show-footer"; import ViewingActionType from "discourse/mixins/viewing-action-type"; -export default Discourse.Route.extend(ShowFooter, ViewingActionType, { - model: function() { - return Discourse.UserBadge.findByUsername(this.modelFor('user').get('username_lower'), {grouped: true}); +export default Discourse.Route.extend(ViewingActionType, { + model() { + return Discourse.UserBadge.findByUsername(this.modelFor("user").get("username_lower"), { grouped: true }); }, - setupController: function(controller, model) { + setupController(controller, model) { this.viewingActionType(-1); - controller.set('model', model); + controller.set("model", model); }, - renderTemplate: function() { - this.render('user/badges', {into: 'user'}); + renderTemplate() { + this.render("user/badges", {into: "user"}); } }); diff --git a/app/assets/javascripts/discourse/routes/user-invited-show.js.es6 b/app/assets/javascripts/discourse/routes/user-invited-show.js.es6 index 6c42105dd..21317f309 100644 --- a/app/assets/javascripts/discourse/routes/user-invited-show.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-invited-show.js.es6 @@ -1,33 +1,32 @@ -import ShowFooter from 'discourse/mixins/show-footer'; -import showModal from 'discourse/lib/show-modal'; +import showModal from "discourse/lib/show-modal"; -export default Discourse.Route.extend(ShowFooter, { +export default Discourse.Route.extend({ - model: function(params) { + model(params) { this.inviteFilter = params.filter; - return Discourse.Invite.findInvitedBy(this.modelFor('user'), params.filter); + return Discourse.Invite.findInvitedBy(this.modelFor("user"), params.filter); }, - afterModel: function(model) { + afterModel(model) { if (!model.can_see_invite_details) { - this.replaceWith('userInvited.show', 'redeemed'); + this.replaceWith("userInvited.show", "redeemed"); } }, setupController(controller, model) { controller.setProperties({ model: model, - user: this.controllerFor('user').get('model'), + user: this.controllerFor("user").get("model"), filter: this.inviteFilter, - searchTerm: '', + searchTerm: "", totalInvites: model.invites.length }); }, actions: { showInvite() { - showModal('invite', { model: this.currentUser }); - this.controllerFor('invite').reset(); + showModal("invite", { model: this.currentUser }); + this.controllerFor("invite").reset(); }, uploadSuccess(filename) { diff --git a/app/assets/javascripts/discourse/routes/user-notifications.js.es6 b/app/assets/javascripts/discourse/routes/user-notifications.js.es6 index a90c131af..2b497d538 100644 --- a/app/assets/javascripts/discourse/routes/user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-notifications.js.es6 @@ -1,7 +1,6 @@ -import ShowFooter from "discourse/mixins/show-footer"; import ViewingActionType from "discourse/mixins/viewing-action-type"; -export default Discourse.Route.extend(ShowFooter, ViewingActionType, { +export default Discourse.Route.extend(ViewingActionType, { actions: { didTransition() { this.controllerFor("user-notifications")._showFooter(); @@ -10,13 +9,13 @@ export default Discourse.Route.extend(ShowFooter, ViewingActionType, { }, model() { - var user = this.modelFor('user'); - return this.store.find('notification', {username: user.get('username')}); + var user = this.modelFor("user"); + return this.store.find("notification", { username: user.get("username") }); }, setupController(controller, model) { - controller.set('model', model); - controller.set('user', this.modelFor('user')); + controller.set("model", model); + controller.set("user", this.modelFor("user")); this.viewingActionType(-1); } });