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

Commit

Permalink
comments_plugin/fix: reload list (#311)
Browse files Browse the repository at this point in the history
reload list after posting and deleting comment
  • Loading branch information
safesurfer authored and hitman401 committed Oct 19, 2017
1 parent f1099ff commit dbd6b4a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions non-editable-comments-web/src/safe_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,14 @@ export default class SafeApi {
postComment(commentModel) {
return new Promise(async (resolve, reject) => {
try {
const updatedList = this.comments.slice(0);
const entriesHandle = await window.safeMutableData.getEntries(this.mData);
const mutationHandle = await window.safeMutableDataEntries.mutate(entriesHandle);
updatedList.unshift(commentModel);
await window.safeMutableDataMutation.insert(mutationHandle, commentModel.id, JSON.stringify(commentModel));
// Without calling applyEntriesMutation the changes wont we saved in the network
await window.safeMutableData.applyEntriesMutation(this.mData, mutationHandle);
window.safeMutableDataMutation.free(mutationHandle);
window.safeMutableDataEntries.free(entriesHandle);
this.comments = updatedList;
this.comments = await this.listComments();
resolve(this.comments);
} catch (err) {
reject(err);
Expand Down Expand Up @@ -286,7 +284,7 @@ export default class SafeApi {
await window.safeMutableData.applyEntriesMutation(this.mData, mutationHandle);
window.safeMutableDataMutation.free(mutationHandle);
window.safeMutableDataEntries.free(entriesHandle);
this.comments.splice(this.comments.indexOf(commentModel), 1);
this.comments = await this.listComments();
resolve(this.comments);
} catch (err) {
reject(err);
Expand Down

0 comments on commit dbd6b4a

Please sign in to comment.