FIX: Clicking navigation pills a second time should refresh the list
you're looking at.
This commit is contained in:
parent
f33ebc512b
commit
b88a8d2416
|
@ -1,13 +1,15 @@
|
||||||
export default {
|
export default {
|
||||||
name: "inject-app-events",
|
name: "inject-app-events",
|
||||||
initialize: function(container, application) {
|
initialize: function(container, application) {
|
||||||
var AppEvents = Ember.Object.extend(Ember.Evented);
|
var appEvents = Ember.Object.createWithMixins(Ember.Evented);
|
||||||
application.register('app-events:main', AppEvents, { singleton: true });
|
application.register('app-events:main', appEvents, { instantiate: false });
|
||||||
|
|
||||||
application.inject('controller', 'appEvents', 'app-events:main');
|
application.inject('controller', 'appEvents', 'app-events:main');
|
||||||
application.inject('component', 'appEvents', 'app-events:main');
|
application.inject('component', 'appEvents', 'app-events:main');
|
||||||
application.inject('route', 'appEvents', 'app-events:main');
|
application.inject('route', 'appEvents', 'app-events:main');
|
||||||
application.inject('view', 'appEvents', 'app-events:main');
|
application.inject('view', 'appEvents', 'app-events:main');
|
||||||
application.inject('model', 'appEvents', 'app-events:main');
|
application.inject('model', 'appEvents', 'app-events:main');
|
||||||
|
|
||||||
|
Discourse.URL.appEvents = appEvents;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -145,8 +145,10 @@ Discourse.URL = Em.Object.createWithMixins({
|
||||||
// TODO: Extract into rules we can inject into the URL handler
|
// TODO: Extract into rules we can inject into the URL handler
|
||||||
if (this.navigatedToHome(oldPath, path)) { return; }
|
if (this.navigatedToHome(oldPath, path)) { return; }
|
||||||
|
|
||||||
if (path.match(/^\/?users\/[^\/]+$/)) {
|
if (oldPath === path) {
|
||||||
path += "/activity";
|
// If navigating to the same path send an app event. Views can watch it
|
||||||
|
// and tell their controllers to refresh
|
||||||
|
this.appEvents.trigger('url:refresh');
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.handleURL(path);
|
return this.handleURL(path);
|
||||||
|
@ -244,12 +246,7 @@ Discourse.URL = Em.Object.createWithMixins({
|
||||||
var homepage = Discourse.Utilities.defaultHomepage();
|
var homepage = Discourse.Utilities.defaultHomepage();
|
||||||
|
|
||||||
if (window.history && window.history.pushState && path === "/" && (oldPath === "/" || oldPath === "/" + homepage)) {
|
if (window.history && window.history.pushState && path === "/" && (oldPath === "/" || oldPath === "/" + homepage)) {
|
||||||
// refresh the list
|
this.appEvents.trigger('url:refresh');
|
||||||
switch (homepage) {
|
|
||||||
case "top" : { this.controllerFor('discovery/top').send('refresh'); break; }
|
|
||||||
case "categories": { this.controllerFor('discovery/categories').send('refresh'); break; }
|
|
||||||
default: { this.controllerFor('discovery/topics').send('refresh'); break; }
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
// A Mixin that a view can use to listen for 'url:refresh' when
|
||||||
|
// it is on screen, and will send an action to the controller to
|
||||||
|
// refresh its data.
|
||||||
|
//
|
||||||
|
// This is useful if you want to get around Ember's default
|
||||||
|
// behavior of not refreshing when navigating to the same place.
|
||||||
|
export default Em.Mixin.create({
|
||||||
|
_initURLRefresh: function() {
|
||||||
|
this.appEvents.on('url:refresh', this, '_urlRefresh');
|
||||||
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
|
_tearDownURLRefresh: function() {
|
||||||
|
this.appEvents.off('url:refresh', this, '_urlRefresh');
|
||||||
|
}.on('willDestroyElement'),
|
||||||
|
|
||||||
|
_urlRefresh: function() {
|
||||||
|
this.get('controller').send('refresh');
|
||||||
|
}
|
||||||
|
});
|
|
@ -1,4 +1,6 @@
|
||||||
export default Discourse.View.extend({
|
import UrlRefresh from 'discourse/mixins/url-refresh';
|
||||||
|
|
||||||
|
export default Discourse.View.extend(UrlRefresh, {
|
||||||
|
|
||||||
orderingChanged: function(){
|
orderingChanged: function(){
|
||||||
if (this.get("controller.ordering")) {
|
if (this.get("controller.ordering")) {
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
export default Discourse.View.extend(Discourse.ScrollTop);
|
import UrlRefresh from 'discourse/mixins/url-refresh';
|
||||||
|
|
||||||
|
export default Discourse.View.extend(Discourse.ScrollTop, UrlRefresh);
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
/**
|
import UrlRefresh from 'discourse/mixins/url-refresh';
|
||||||
This view handles rendering of a list of topics under discovery, with support
|
|
||||||
for loading more as well as remembering your scroll position.
|
|
||||||
|
|
||||||
@class DiscoveryTopicsView
|
export default Discourse.View.extend(Discourse.LoadMore, UrlRefresh, {
|
||||||
@extends Discourse.View
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
export default Discourse.View.extend(Discourse.LoadMore, {
|
|
||||||
eyelineSelector: '.topic-list-item',
|
eyelineSelector: '.topic-list-item',
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -5,11 +5,26 @@ export default Discourse.View.extend({
|
||||||
classNameBindings: ['controller.visible::hidden', 'controller.showBadges'],
|
classNameBindings: ['controller.visible::hidden', 'controller.showBadges'],
|
||||||
|
|
||||||
_setup: function() {
|
_setup: function() {
|
||||||
|
var self = this;
|
||||||
|
this.appEvents.on('poster:expand', this, '_posterExpand');
|
||||||
|
|
||||||
|
$('html').off(clickOutsideEventName).on(clickOutsideEventName, function(e) {
|
||||||
|
if (self.get('controller.visible')) {
|
||||||
|
var $target = $(e.target);
|
||||||
|
if ($target.closest('.trigger-expansion').length > 0) { return; }
|
||||||
|
if (self.$().has(e.target).length !== 0) { return; }
|
||||||
|
|
||||||
|
self.get('controller').close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
|
_posterExpand: function(target) {
|
||||||
|
if (!target) { return; }
|
||||||
var self = this,
|
var self = this,
|
||||||
width = this.$().width();
|
width = this.$().width();
|
||||||
|
|
||||||
this.appEvents.on('poster:expand', function(target) {
|
|
||||||
if (!target) { return; }
|
|
||||||
Em.run.schedule('afterRender', function() {
|
Em.run.schedule('afterRender', function() {
|
||||||
if (target) {
|
if (target) {
|
||||||
var position = target.offset();
|
var position = target.offset();
|
||||||
|
@ -25,24 +40,11 @@ export default Discourse.View.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
|
|
||||||
$('html').off(clickOutsideEventName).on(clickOutsideEventName, function(e) {
|
|
||||||
if (self.get('controller.visible')) {
|
|
||||||
var $target = $(e.target);
|
|
||||||
if ($target.closest('.trigger-expansion').length > 0) { return; }
|
|
||||||
if (self.$().has(e.target).length !== 0) { return; }
|
|
||||||
|
|
||||||
self.get('controller').close();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}.on('didInsertElement'),
|
|
||||||
|
|
||||||
_removeEvents: function() {
|
_removeEvents: function() {
|
||||||
$('html').off(clickOutsideEventName);
|
$('html').off(clickOutsideEventName);
|
||||||
this.appEvents.off('poster:expand');
|
this.appEvents.off('poster:expand', this, '_posterExpand');
|
||||||
}.on('willDestroyElement')
|
}.on('willDestroyElement')
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue