mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-18 20:47:33 +01:00
fix: render new post in feed when posting via quick create
This commit is contained in:
@@ -9,13 +9,8 @@ define('forum/world', [
|
||||
translator, quickreply) {
|
||||
const World = {};
|
||||
|
||||
$(window).on('action:ajaxify.start', function () {
|
||||
categoryTools.removeListeners();
|
||||
});
|
||||
|
||||
World.init = function () {
|
||||
app.enterRoom('world');
|
||||
categoryTools.init($('#world-feed'));
|
||||
quickreply.init({
|
||||
route: '/topics',
|
||||
body: {
|
||||
@@ -28,6 +23,14 @@ define('forum/world', [
|
||||
handleButtons();
|
||||
handleHelp();
|
||||
|
||||
categoryTools.init($('#world-feed'));
|
||||
socket.on('event:new_post', onNewPost);
|
||||
$(window).one('action:ajaxify.start', function () {
|
||||
categoryTools.removeListeners();
|
||||
socket.removeListener('event:new_post', onNewPost);
|
||||
});
|
||||
|
||||
|
||||
// Add label to sort
|
||||
const sortLabelEl = document.getElementById('sort-label');
|
||||
const sortOptionsEl = document.getElementById('sort-options');
|
||||
@@ -217,5 +220,15 @@ define('forum/world', [
|
||||
});
|
||||
}
|
||||
|
||||
async function onNewPost({ posts }) {
|
||||
const feedEl = document.getElementById('world-feed');
|
||||
const html = await app.parseAndTranslate('world', 'posts', { posts });
|
||||
if (!feedEl || !html) {
|
||||
return;
|
||||
}
|
||||
|
||||
feedEl.prepend(...html);
|
||||
}
|
||||
|
||||
return World;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user