mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 11:01:20 +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) {
|
translator, quickreply) {
|
||||||
const World = {};
|
const World = {};
|
||||||
|
|
||||||
$(window).on('action:ajaxify.start', function () {
|
|
||||||
categoryTools.removeListeners();
|
|
||||||
});
|
|
||||||
|
|
||||||
World.init = function () {
|
World.init = function () {
|
||||||
app.enterRoom('world');
|
app.enterRoom('world');
|
||||||
categoryTools.init($('#world-feed'));
|
|
||||||
quickreply.init({
|
quickreply.init({
|
||||||
route: '/topics',
|
route: '/topics',
|
||||||
body: {
|
body: {
|
||||||
@@ -28,6 +23,14 @@ define('forum/world', [
|
|||||||
handleButtons();
|
handleButtons();
|
||||||
handleHelp();
|
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
|
// Add label to sort
|
||||||
const sortLabelEl = document.getElementById('sort-label');
|
const sortLabelEl = document.getElementById('sort-label');
|
||||||
const sortOptionsEl = document.getElementById('sort-options');
|
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;
|
return World;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user