nodebb-plugin-composer-default 10.2.46 → 10.2.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-composer-default",
3
- "version": "10.2.46",
3
+ "version": "10.2.48",
4
4
  "description": "Default composer for NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -94,7 +94,7 @@ define('composer/categoryList', [
94
94
 
95
95
  async function changeCategory(postContainer, postData, selectedCategory) {
96
96
  postData.cid = selectedCategory.cid;
97
- const categoryData = await window.fetch(`${config.relative_path}/api/category/${selectedCategory.cid}`).then(r => r.json());
97
+ const categoryData = await window.fetch(`${config.relative_path}/api/category/${encodeURIComponent(selectedCategory.cid)}`).then(r => r.json());
98
98
  postData.category = categoryData;
99
99
  updateTaskbarByCategory(postContainer, categoryData);
100
100
  require(['composer/scheduler', 'composer/tags', 'composer/post-queue'], function (scheduler, tags, postQueue) {
@@ -430,11 +430,14 @@ define('composer', [
430
430
  };
431
431
 
432
432
  async function getSelectedCategory(postData) {
433
- if (ajaxify.data.template.category && parseInt(postData.cid, 10) === parseInt(ajaxify.data.cid, 10)) {
433
+ const { template } = ajaxify.data;
434
+ const cid = parseInt(postData.cid, 10);
435
+ if ((template.category || template.world) && cid === parseInt(ajaxify.data.cid, 10)) {
434
436
  // no need to load data if we are already on the category page
435
437
  return ajaxify.data;
436
- } else if (parseInt(postData.cid, 10)) {
437
- return await api.get(`/api/category/${postData.cid}`, {});
438
+ } else if (cid) {
439
+ const categoryUrl = cid !== -1 ? `/api/category/${encodeURIComponent(postData.cid)}` : `/api/world`;
440
+ return await api.get(categoryUrl, {});
438
441
  }
439
442
  return null;
440
443
  }