FIX: Fix hashtag decoration on later pages of user activity stream (#24261)
Followup to 545e92039c
This commit fixes an issue where hashtags on user activity stream
items past page 1 did not get decorated. This is because of a bug
in the user stream component, where it was trying to get stream
items to decorate after the AJAX call but before they had been
rendered by Ember. This can be fixed by wrapping this decoration
logic in later() to run on the next runloop.
This commit is contained in:
parent
986fb522be
commit
184f038cbf
|
@ -1,5 +1,6 @@
|
|||
import Component from "@ember/component";
|
||||
import { on } from "@ember/object/evented";
|
||||
import { later } from "@ember/runloop";
|
||||
import { inject as service } from "@ember/service";
|
||||
import $ from "jquery";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
@ -129,13 +130,21 @@ export default Component.extend(LoadMore, {
|
|||
const stream = this.stream;
|
||||
stream.findItems().then(() => {
|
||||
this.set("loading", false);
|
||||
let element = this._lastDecoratedElement?.nextElementSibling;
|
||||
while (element) {
|
||||
this.trigger("user-stream:new-item-inserted", element);
|
||||
this.appEvents.trigger("decorate-non-stream-cooked-element", element);
|
||||
element = element.nextElementSibling;
|
||||
}
|
||||
this._updateLastDecoratedElement();
|
||||
|
||||
// The next elements are not rendered on the page yet, we need to
|
||||
// wait for that before trying to decorate them.
|
||||
later(() => {
|
||||
let element = this._lastDecoratedElement?.nextElementSibling;
|
||||
while (element) {
|
||||
this.trigger("user-stream:new-item-inserted", element);
|
||||
this.appEvents.trigger(
|
||||
"decorate-non-stream-cooked-element",
|
||||
element
|
||||
);
|
||||
element = element.nextElementSibling;
|
||||
}
|
||||
this._updateLastDecoratedElement();
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue