Implement unfollow, unlike, unrepost
This commit is contained in:
parent
aabde2b401
commit
a8c8286b88
6 changed files with 61 additions and 41 deletions
|
@ -59,13 +59,17 @@ export class FeedViewItemModel implements GetFeedView.FeedItem {
|
|||
|
||||
async toggleLike() {
|
||||
if (this.myState.like) {
|
||||
await apilib.unlike(this.rootStore.api, 'alice.test', this.uri)
|
||||
await apilib.unlike(this.rootStore.api, this.myState.like)
|
||||
runInAction(() => {
|
||||
this.likeCount--
|
||||
this.myState.like = undefined
|
||||
})
|
||||
} else {
|
||||
const res = await apilib.like(this.rootStore.api, 'alice.test', this.uri)
|
||||
const res = await apilib.like(
|
||||
this.rootStore.api,
|
||||
'did:test:alice',
|
||||
this.uri,
|
||||
)
|
||||
runInAction(() => {
|
||||
this.likeCount++
|
||||
this.myState.like = res.uri
|
||||
|
@ -75,7 +79,7 @@ export class FeedViewItemModel implements GetFeedView.FeedItem {
|
|||
|
||||
async toggleRepost() {
|
||||
if (this.myState.repost) {
|
||||
await apilib.unrepost(this.rootStore.api, 'alice.test', this.uri)
|
||||
await apilib.unrepost(this.rootStore.api, this.myState.repost)
|
||||
runInAction(() => {
|
||||
this.repostCount--
|
||||
this.myState.repost = undefined
|
||||
|
@ -83,7 +87,7 @@ export class FeedViewItemModel implements GetFeedView.FeedItem {
|
|||
} else {
|
||||
const res = await apilib.repost(
|
||||
this.rootStore.api,
|
||||
'alice.test',
|
||||
'did:test:alice',
|
||||
this.uri,
|
||||
)
|
||||
runInAction(() => {
|
||||
|
|
|
@ -95,13 +95,17 @@ export class PostThreadViewPostModel implements GetPostThread.Post {
|
|||
|
||||
async toggleLike() {
|
||||
if (this.myState.like) {
|
||||
await apilib.unlike(this.rootStore.api, 'alice.test', this.uri)
|
||||
await apilib.unlike(this.rootStore.api, this.myState.like)
|
||||
runInAction(() => {
|
||||
this.likeCount--
|
||||
this.myState.like = undefined
|
||||
})
|
||||
} else {
|
||||
const res = await apilib.like(this.rootStore.api, 'alice.test', this.uri)
|
||||
const res = await apilib.like(
|
||||
this.rootStore.api,
|
||||
'did:test:alice',
|
||||
this.uri,
|
||||
)
|
||||
runInAction(() => {
|
||||
this.likeCount++
|
||||
this.myState.like = res.uri
|
||||
|
@ -111,7 +115,7 @@ export class PostThreadViewPostModel implements GetPostThread.Post {
|
|||
|
||||
async toggleRepost() {
|
||||
if (this.myState.repost) {
|
||||
await apilib.unrepost(this.rootStore.api, 'alice.test', this.uri)
|
||||
await apilib.unrepost(this.rootStore.api, this.myState.repost)
|
||||
runInAction(() => {
|
||||
this.repostCount--
|
||||
this.myState.repost = undefined
|
||||
|
@ -119,7 +123,7 @@ export class PostThreadViewPostModel implements GetPostThread.Post {
|
|||
} else {
|
||||
const res = await apilib.repost(
|
||||
this.rootStore.api,
|
||||
'alice.test',
|
||||
'did:test:alice',
|
||||
this.uri,
|
||||
)
|
||||
runInAction(() => {
|
||||
|
|
|
@ -74,9 +74,7 @@ export class ProfileViewModel {
|
|||
throw new Error('Not logged in')
|
||||
}
|
||||
if (this.myState.follow) {
|
||||
await apilib.unfollow(this.rootStore.api, this.rootStore.me.did, {
|
||||
did: this.did,
|
||||
})
|
||||
await apilib.unfollow(this.rootStore.api, this.myState.follow)
|
||||
runInAction(() => {
|
||||
this.followersCount--
|
||||
this.myState.follow = undefined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue