mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-25 16:04:22 -05:00
FIX: Can force all shadow trees to rerender
This commit is contained in:
parent
9eed95dc7b
commit
5d9278c098
5 changed files with 27 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { diff, patch } from 'virtual-dom';
|
import { diff, patch } from 'virtual-dom';
|
||||||
import { WidgetClickHook } from 'discourse/widgets/click-hook';
|
import { WidgetClickHook } from 'discourse/widgets/click-hook';
|
||||||
|
import { renderedKey } from 'discourse/widgets/widget';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
_tree: null,
|
_tree: null,
|
||||||
|
@ -51,6 +52,8 @@ export default Ember.Component.extend({
|
||||||
this._afterRender();
|
this._afterRender();
|
||||||
this._afterRender = null;
|
this._afterRender = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderedKey('*');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,9 +150,13 @@ export default MountWidget.extend({
|
||||||
$('button.widget-button').removeClass('d-hover');
|
$('button.widget-button').removeClass('d-hover');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.appEvents.on('post-stream:refresh', postId => {
|
this.appEvents.on('post-stream:refresh', args => {
|
||||||
if (postId) {
|
if (args) {
|
||||||
keyDirty(`post-${postId}`);
|
if (args.id) {
|
||||||
|
keyDirty(`post-${args.id}`);
|
||||||
|
} else if (args.force) {
|
||||||
|
keyDirty(`*`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.queueRerender();
|
this.queueRerender();
|
||||||
});
|
});
|
||||||
|
|
|
@ -310,7 +310,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||||
} else {
|
} else {
|
||||||
return this.get("model").toggleBookmark().then(changedIds => {
|
return this.get("model").toggleBookmark().then(changedIds => {
|
||||||
if (!changedIds) { return; }
|
if (!changedIds) { return; }
|
||||||
changedIds.forEach(id => this.appEvents.trigger('post-stream:refresh', id));
|
changedIds.forEach(id => this.appEvents.trigger('post-stream:refresh', { id }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -326,14 +326,14 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||||
selectedPosts.addObjects(posts);
|
selectedPosts.addObjects(posts);
|
||||||
}
|
}
|
||||||
this.set('allPostsSelected', true);
|
this.set('allPostsSelected', true);
|
||||||
this.appEvents.trigger('post-stream:refresh');
|
this.appEvents.trigger('post-stream:refresh', { force: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
deselectAll() {
|
deselectAll() {
|
||||||
this.get('selectedPosts').clear();
|
this.get('selectedPosts').clear();
|
||||||
this.get('selectedReplies').clear();
|
this.get('selectedReplies').clear();
|
||||||
this.set('allPostsSelected', false);
|
this.set('allPostsSelected', false);
|
||||||
this.appEvents.trigger('post-stream:refresh');
|
this.appEvents.trigger('post-stream:refresh', { force: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleParticipant(user) {
|
toggleParticipant(user) {
|
||||||
|
@ -354,7 +354,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||||
|
|
||||||
toggleMultiSelect() {
|
toggleMultiSelect() {
|
||||||
this.toggleProperty('multiSelect');
|
this.toggleProperty('multiSelect');
|
||||||
this.appEvents.trigger('post-stream:refresh');
|
this.appEvents.trigger('post-stream:refresh', { force: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
finishedEditingTopic() {
|
finishedEditingTopic() {
|
||||||
|
@ -643,7 +643,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||||
// Unsubscribe before subscribing again
|
// Unsubscribe before subscribing again
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
|
|
||||||
const refresh = (id) => this.appEvents.trigger('post-stream:refresh', id);
|
const refresh = (id) => this.appEvents.trigger('post-stream:refresh', { id });
|
||||||
|
|
||||||
this.messageBus.subscribe("/topic/" + this.get('model.id'), data => {
|
this.messageBus.subscribe("/topic/" + this.get('model.id'), data => {
|
||||||
const topic = this.get('model');
|
const topic = this.get('model');
|
||||||
|
@ -729,7 +729,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||||
postStream.get('posts').forEach(post => {
|
postStream.get('posts').forEach(post => {
|
||||||
if (!post.read && postNumbers.indexOf(post.post_number) !== -1) {
|
if (!post.read && postNumbers.indexOf(post.post_number) !== -1) {
|
||||||
post.set('read', true);
|
post.set('read', true);
|
||||||
this.appEvents.trigger('post-stream:refresh', post.id);
|
this.appEvents.trigger('post-stream:refresh', { id: post.id });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@ export default {
|
||||||
// TODO: Use ember closure actions
|
// TODO: Use ember closure actions
|
||||||
const result = topicController._actions[action].call(topicController, post);
|
const result = topicController._actions[action].call(topicController, post);
|
||||||
if (result && result.then) {
|
if (result && result.then) {
|
||||||
this.appEvents.trigger('post-stream:refresh', selectedPostId);
|
this.appEvents.trigger('post-stream:refresh', { id: selectedPostId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,16 @@ import { h } from 'virtual-dom';
|
||||||
function emptyContent() { }
|
function emptyContent() { }
|
||||||
|
|
||||||
const _registry = {};
|
const _registry = {};
|
||||||
const _dirty = {};
|
let _dirty = {};
|
||||||
|
|
||||||
export function keyDirty(key) {
|
export function keyDirty(key) {
|
||||||
_dirty[key] = true;
|
_dirty[key] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function renderedKey(key) {
|
||||||
|
delete _dirty[key];
|
||||||
|
}
|
||||||
|
|
||||||
function drawWidget(builder, attrs, state) {
|
function drawWidget(builder, attrs, state) {
|
||||||
const properties = {};
|
const properties = {};
|
||||||
|
|
||||||
|
@ -95,7 +99,11 @@ export default class Widget {
|
||||||
|
|
||||||
if (prev && prev.shadowTree) {
|
if (prev && prev.shadowTree) {
|
||||||
this.shadowTree = true;
|
this.shadowTree = true;
|
||||||
if (!_dirty[prev.key]) { return prev.vnode; }
|
if (!_dirty[prev.key] && !_dirty['*']) {
|
||||||
|
return prev.vnode;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderedKey(prev.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.draw(h, this.attrs, this.state);
|
return this.draw(h, this.attrs, this.state);
|
||||||
|
|
Loading…
Reference in a new issue