Skip to content
This repository was archived by the owner on Jan 7, 2020. It is now read-only.

Commit dbd6b4a

Browse files
safesurferhitman401
authored andcommitted
comments_plugin/fix: reload list (#311)
reload list after posting and deleting comment
1 parent f1099ff commit dbd6b4a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

non-editable-comments-web/src/safe_api.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,14 @@ export default class SafeApi {
228228
postComment(commentModel) {
229229
return new Promise(async (resolve, reject) => {
230230
try {
231-
const updatedList = this.comments.slice(0);
232231
const entriesHandle = await window.safeMutableData.getEntries(this.mData);
233232
const mutationHandle = await window.safeMutableDataEntries.mutate(entriesHandle);
234-
updatedList.unshift(commentModel);
235233
await window.safeMutableDataMutation.insert(mutationHandle, commentModel.id, JSON.stringify(commentModel));
236234
// Without calling applyEntriesMutation the changes wont we saved in the network
237235
await window.safeMutableData.applyEntriesMutation(this.mData, mutationHandle);
238236
window.safeMutableDataMutation.free(mutationHandle);
239237
window.safeMutableDataEntries.free(entriesHandle);
240-
this.comments = updatedList;
238+
this.comments = await this.listComments();
241239
resolve(this.comments);
242240
} catch (err) {
243241
reject(err);
@@ -286,7 +284,7 @@ export default class SafeApi {
286284
await window.safeMutableData.applyEntriesMutation(this.mData, mutationHandle);
287285
window.safeMutableDataMutation.free(mutationHandle);
288286
window.safeMutableDataEntries.free(entriesHandle);
289-
this.comments.splice(this.comments.indexOf(commentModel), 1);
287+
this.comments = await this.listComments();
290288
resolve(this.comments);
291289
} catch (err) {
292290
reject(err);

0 commit comments

Comments
 (0)