FIX: match drafts using key when deleting

FIX: match drafts using key when deleting

Using “sequence” when removing drafts was buggy, it would remove more than one draft from the stream sometimes.

diff --git a/app/assets/javascripts/discourse/models/user-drafts-stream.js.es6 b/app/assets/javascripts/discourse/models/user-drafts-stream.js.es6
index 3beef17..116b75f 100644
--- a/app/assets/javascripts/discourse/models/user-drafts-stream.js.es6
+++ b/app/assets/javascripts/discourse/models/user-drafts-stream.js.es6
@@ -45,7 +45,7 @@ export default RestModel.extend({
 
   remove(draft) {
     let content = this.get("content").filter(
-      item => item.sequence !== draft.sequence
+      item => item.draft_key !== draft.draft_key
     );
     this.setProperties({ content, itemsLoaded: content.length });
   },

GitHub sha: 84a3da4b

2 Likes

We might want a test here to ensure we don’t regress.

1 Like

Add test for user drafts stream