handle cid=-1 in composer when trying to load the selected category
This commit is contained in:
Barış Soner Uşaklı 2025-02-22 17:11:42 -05:00
parent 24e629cd33
commit c7c4ecbff4

View file

@ -430,11 +430,14 @@ define('composer', [
};

async function getSelectedCategory(postData) {
if (ajaxify.data.template.category && parseInt(postData.cid, 10) === parseInt(ajaxify.data.cid, 10)) {
const { template } = ajaxify.data;
const cid = parseInt(postData.cid, 10);
if ((template.category || template.world) && cid === parseInt(ajaxify.data.cid, 10)) {
// no need to load data if we are already on the category page
return ajaxify.data;
} else if (parseInt(postData.cid, 10)) {
return await api.get(`/api/category/${postData.cid}`, {});
} else if (cid) {
const categoryUrl = cid !== -1 ? `/api/category/${postData.cid}` : `/api/world`;
return await api.get(categoryUrl, {});
}
return null;
}