aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorrr-2016-09-10 15:23:44 +0200
committerrr-2016-09-10 15:23:54 +0200
commitf31f67bfec87c97adf9be1ed84160c26cf67cf78 (patch)
tree3eb0255d3ee6f118df732b47a167516dfd591b9c /client
parent0f0e6c4e2434a89b84a345129225f7ff0720531c (diff)
client/comments: fix adding comment after voting
Diffstat (limited to 'client')
-rw-r--r--client/js/models/post.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/client/js/models/post.js b/client/js/models/post.js
index 7125917..7e32143 100644
--- a/client/js/models/post.js
+++ b/client/js/models/post.js
@@ -7,10 +7,23 @@ const NoteList = require('./note_list.js');
const CommentList = require('./comment_list.js');
const misc = require('../util/misc.js');
+function _syncObservableCollection(target, plainList) {
+ target.clear();
+ for (let item of (plainList || [])) {
+ target.add(target.constructor._itemClass.fromResponse(item));
+ }
+}
+
class Post extends events.EventTarget {
constructor() {
super();
this._orig = {};
+
+ for (let obj of [this, this._orig]) {
+ obj._notes = new NoteList();
+ obj._comments = new CommentList();
+ }
+
this._updateFromResponse({});
}
@@ -264,9 +277,6 @@ class Post extends events.EventTarget {
_flags: [...response.flags || []],
_tags: [...response.tags || []],
- _notes: NoteList.fromResponse([...response.notes || []]),
- _comments: CommentList.fromResponse(
- [...response.comments || []]),
_relations: [...response.relations || []],
_score: response.score,
@@ -277,6 +287,11 @@ class Post extends events.EventTarget {
_hasCustomThumbnail: response.hasCustomThumbnail,
});
+ for (let obj of [this, this._orig]) {
+ _syncObservableCollection(obj._notes, response.notes);
+ _syncObservableCollection(obj._comments, response.comments);
+ }
+
Object.assign(this, map());
Object.assign(this._orig, map());
}

© 2015 - 2026 Jakob L. Kreuze