fix: closes #13666, update category label

on topic move if we are not on category page
This commit is contained in:
Barış Soner Uşaklı
2025-12-06 20:08:05 -05:00
parent ebf2a2c5af
commit 193aaf55d5
3 changed files with 16 additions and 3 deletions

View File

@@ -284,8 +284,20 @@ define('forum/category/tools', [
topic.find('[component="topic/locked"]').toggleClass('hidden', !data.isLocked);
}
function onTopicMoved(data) {
getTopicEl(data.tid).remove();
async function onTopicMoved(data) {
if (ajaxify.data.template.category) {
getTopicEl(data.tid).remove();
} else {
const category = await api.get(`/categories/${data.toCid}`);
const html = await app.parseAndTranslate('partials/topics_list', {
topics: [{
...data,
category,
}],
});
const categoryLabelSelector = `[component="category/topic"][data-tid="${data.tid}"] [component="topic/category"]`;
$(categoryLabelSelector).replaceWith(html.find(categoryLabelSelector));
}
}
function onTopicPurged(data) {

View File

@@ -113,7 +113,7 @@ module.exports = function (utils, Benchpress, relative_path) {
}
const href = tag === 'a' ? `href="${relative_path}/category/${category.slug}"` : '';
return `<${tag} ${href} class="badge px-1 text-truncate text-decoration-none ${className}" style="color: ${category.color};background-color: ${category.bgColor};border-color: ${category.bgColor}!important; max-width: 70vw;">
return `<${tag} ${href} component="topic/category" class="badge px-1 text-truncate text-decoration-none ${className}" style="color: ${category.color};background-color: ${category.bgColor};border-color: ${category.bgColor}!important; max-width: 70vw;">
${category.icon && category.icon !== 'fa-nbb-none' ? `<i class="fa fa-fw ${category.icon}"></i>` : ''}
${category.name}
</${tag}>`;

View File

@@ -309,6 +309,7 @@ topicsAPI.move = async (caller, { tid, cid }) => {
throw new Error('[[error:no-privileges]]');
}
const topicData = await topics.getTopicFields(tid, ['tid', 'cid', 'mainPid', 'slug', 'deleted']);
topicData.toCid = cid;
if (!cids.includes(topicData.cid)) {
cids.push(topicData.cid);
}