'use strict'; define('forum/topic/replies', ['forum/topic/posts', 'hooks', 'alerts'], function (posts, hooks, alerts) { const Replies = {}; Replies.init = function (button) { const post = button.closest('[data-pid]'); const pid = post.data('pid'); const open = button.find('[component="post/replies/open"]'); const loading = button.find('[component="post/replies/loading"]'); const close = button.find('[component="post/replies/close"]'); if (open.is(':not(.hidden)') && loading.is('.hidden')) { open.addClass('hidden'); loading.removeClass('hidden'); socket.emit('posts.getReplies', pid, function (err, postData) { loading.addClass('hidden'); if (err) { open.removeClass('hidden'); return alerts.error(err); } close.removeClass('hidden'); postData.forEach((post, index) => { if (post) { post.index = index; } }); posts.modifyPostsByPrivileges(postData); const tplData = { posts: postData, privileges: ajaxify.data.privileges, 'downvote:disabled': ajaxify.data['downvote:disabled'], 'reputation:disabled': ajaxify.data['reputation:disabled'], loggedIn: !!app.user.uid, hideReplies: config.hasOwnProperty('showNestedReplies') ? !config.showNestedReplies : true, }; app.parseAndTranslate('topic', 'posts', tplData, async function (html) { const repliesEl = $('