Handle post deletions by removing from active views (close #37)
This commit is contained in:
parent
ace0e6bfd9
commit
ebc2033d18
7 changed files with 59 additions and 4 deletions
|
@ -173,6 +173,7 @@ export class PostThreadViewPostModel {
|
|||
did: this.post.author.did,
|
||||
rkey: new AtUri(this.post.uri).rkey,
|
||||
})
|
||||
this.rootStore.emitPostDeleted(this.post.uri)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,6 +230,14 @@ export class PostThreadViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any event listeners. Returns a cleanup function.
|
||||
*/
|
||||
registerListeners() {
|
||||
const sub = this.rootStore.onPostDeleted(this.onPostDeleted.bind(this))
|
||||
return () => sub.remove()
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset and load
|
||||
*/
|
||||
|
@ -246,6 +255,13 @@ export class PostThreadViewModel {
|
|||
this._load()
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes when posts are deleted
|
||||
*/
|
||||
onPostDeleted(_uri: string) {
|
||||
this.refresh()
|
||||
}
|
||||
|
||||
// state transitions
|
||||
// =
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue