mirror of
https://hk.gh-proxy.com/https://github.com/NodeBB/nodebb-plugin-composer-default.git
synced 2025-10-04 04:41:20 +08:00
handle cid=-1 in composer when trying to load the selected category
This commit is contained in:
parent
24e629cd33
commit
c7c4ecbff4
1 changed files with 6 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue