nodebb-plugin-composer-default 10.3.23 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-composer-default",
3
- "version": "10.3.23",
3
+ "version": "10.3.24",
4
4
  "description": "Default composer for NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -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