nodebb-plugin-composer-default 10.3.22 → 10.3.24

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/library.js CHANGED
@@ -158,7 +158,7 @@ plugin.filterComposerBuild = async function (hookData) {
158
158
  isMain = true;
159
159
  }
160
160
  globalPrivileges['topics:tag'] = canTagTopics;
161
- const cid = parseInt(req.query.cid, 10);
161
+ const cid = req.query.cid || '';
162
162
  const topicTitle = topicData && topicData.title ?
163
163
  topicData.title :
164
164
  validator.escape(String(req.query.title || ''));
@@ -198,9 +198,9 @@ plugin.filterComposerBuild = async function (hookData) {
198
198
  minimumTagLength: meta.config.minimumTagLength || 3,
199
199
  maximumTagLength: meta.config.maximumTagLength || 15,
200
200
  tagWhitelist: tagWhitelist,
201
- selectedCategory: cid ? categoryData : null,
202
- minTags: categoryData.minTags,
203
- maxTags: categoryData.maxTags,
201
+ selectedCategory: categoryData || null,
202
+ minTags: categoryData && categoryData.minTags,
203
+ maxTags: categoryData && categoryData.maxTags,
204
204
 
205
205
  isTopic: !!req.query.cid,
206
206
  isEditing: isEditing,
@@ -282,14 +282,14 @@ async function isModerator(req) {
282
282
  }
283
283
 
284
284
  async function canTag(req) {
285
- if (parseInt(req.query.cid, 10)) {
285
+ if (req.query.cid) {
286
286
  return await privileges.categories.can('topics:tag', req.query.cid, req.uid);
287
287
  }
288
288
  return true;
289
289
  }
290
290
 
291
291
  async function canSchedule(req) {
292
- if (parseInt(req.query.cid, 10)) {
292
+ if (req.query.cid) {
293
293
  return await privileges.categories.can('topics:schedule', req.query.cid, req.uid);
294
294
  }
295
295
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-composer-default",
3
- "version": "10.3.22",
3
+ "version": "10.3.24",
4
4
  "description": "Default composer for NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  define('composer/categoryList', [
4
- 'categorySelector', 'taskbar', 'api',
5
- ], function (categorySelector, taskbar, api) {
4
+ 'categorySelector', 'taskbar', 'api', 'alerts'
5
+ ], function (categorySelector, taskbar, api, alerts) {
6
6
  const categoryList = {};
7
7
 
8
8
  let selector;
@@ -71,10 +71,10 @@ define('composer/categoryList', [
71
71
  };
72
72
 
73
73
  categoryList.updateTaskbar = function (postContainer, postData) {
74
- if (parseInt(postData.cid, 10)) {
74
+ if (postData.cid) {
75
75
  api.get(`/categories/${postData.cid}`, {}).then(function (category) {
76
76
  updateTaskbarByCategory(postContainer, category);
77
- });
77
+ }).catch(alerts.error);
78
78
  }
79
79
  };
80
80
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
3
+ define('composer/drafts', ['api', 'hooks', 'alerts'], function (api, hooks, alerts) {
4
4
  const drafts = {};
5
5
  const draftSaveDelay = 1000;
6
6
  drafts.init = function (postContainer, postData) {
@@ -78,7 +78,7 @@ define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
78
78
  }
79
79
  };
80
80
 
81
- function saveDraft(postContainer, draftIconEl, postData) {
81
+ async function saveDraft(postContainer, draftIconEl, postData) {
82
82
  if (canSave(app.user.uid ? 'localStorage' : 'sessionStorage') && postData && postData.save_id && postContainer.length) {
83
83
  const titleEl = postContainer.find('input.title');
84
84
  const title = titleEl && titleEl.length && titleEl.val();
@@ -114,16 +114,17 @@ define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
114
114
  draftData.handle = postContainer.find('input.handle').val();
115
115
  }
116
116
 
117
+ await hooks.fire('filter:composer.drafts.save', { draft: draftData, postData, postContainer });
118
+
117
119
  // save all draft data into single item as json
118
120
  storage.setItem(postData.save_id, JSON.stringify(draftData));
119
121
 
120
122
  $(window).trigger('action:composer.drafts.save', {
121
- storage: storage,
122
- postData: postData,
123
- postContainer: postContainer,
123
+ storage,
124
+ postData,
125
+ postContainer,
124
126
  });
125
127
  draftIconEl.toggleClass('active', true);
126
-
127
128
  }
128
129
  }
129
130
 
package/websockets.js CHANGED
@@ -15,7 +15,7 @@ Sockets.push = async function (socket, pid) {
15
15
  }
16
16
 
17
17
  const postData = await posts.getPostFields(pid, ['content', 'sourceContent', 'tid', 'uid', 'handle', 'timestamp']);
18
- if (!postData && !postData.content) {
18
+ if (!postData || (!postData.content && !postData.sourceContent)) {
19
19
  throw new Error('[[error:invalid-pid]]');
20
20
  }
21
21