This repository was archived by the owner on Jan 7, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed
Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments