about summary refs log tree commit diff
path: root/src/state/models
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-10-03 11:17:12 -0500
committerPaul Frazee <pfrazee@gmail.com>2022-10-03 11:17:12 -0500
commit2058505bf12c0ddf145bd00182da96d0cf5e8f53 (patch)
treeb8012a04ab924d5147fa7f17f47c3b66ceeaa83b /src/state/models
parentc7d7e152a0e067a95b3d700147768d4244e464d1 (diff)
downloadvoidsky-2058505bf12c0ddf145bd00182da96d0cf5e8f53.tar.zst
Fix to auth of mutation ops
Diffstat (limited to 'src/state/models')
-rw-r--r--src/state/models/feed-view.ts16
-rw-r--r--src/state/models/post-thread-view.ts16
-rw-r--r--src/state/models/profile-view.ts8
3 files changed, 10 insertions, 30 deletions
diff --git a/src/state/models/feed-view.ts b/src/state/models/feed-view.ts
index 585bbce28..9fd024032 100644
--- a/src/state/models/feed-view.ts
+++ b/src/state/models/feed-view.ts
@@ -61,17 +61,13 @@ export class FeedViewItemModel implements GetFeedView.FeedItem {
 
   async toggleLike() {
     if (this.myState.like) {
-      await apilib.unlike(this.rootStore.api, this.myState.like)
+      await apilib.unlike(this.rootStore, this.myState.like)
       runInAction(() => {
         this.likeCount--
         this.myState.like = undefined
       })
     } else {
-      const res = await apilib.like(
-        this.rootStore.api,
-        'did:test:alice',
-        this.uri,
-      )
+      const res = await apilib.like(this.rootStore, this.uri)
       runInAction(() => {
         this.likeCount++
         this.myState.like = res.uri
@@ -81,17 +77,13 @@ export class FeedViewItemModel implements GetFeedView.FeedItem {
 
   async toggleRepost() {
     if (this.myState.repost) {
-      await apilib.unrepost(this.rootStore.api, this.myState.repost)
+      await apilib.unrepost(this.rootStore, this.myState.repost)
       runInAction(() => {
         this.repostCount--
         this.myState.repost = undefined
       })
     } else {
-      const res = await apilib.repost(
-        this.rootStore.api,
-        'did:test:alice',
-        this.uri,
-      )
+      const res = await apilib.repost(this.rootStore, this.uri)
       runInAction(() => {
         this.repostCount++
         this.myState.repost = res.uri
diff --git a/src/state/models/post-thread-view.ts b/src/state/models/post-thread-view.ts
index 923562c5a..4fb9e75f6 100644
--- a/src/state/models/post-thread-view.ts
+++ b/src/state/models/post-thread-view.ts
@@ -106,17 +106,13 @@ export class PostThreadViewPostModel implements GetPostThread.Post {
 
   async toggleLike() {
     if (this.myState.like) {
-      await apilib.unlike(this.rootStore.api, this.myState.like)
+      await apilib.unlike(this.rootStore, this.myState.like)
       runInAction(() => {
         this.likeCount--
         this.myState.like = undefined
       })
     } else {
-      const res = await apilib.like(
-        this.rootStore.api,
-        'did:test:alice',
-        this.uri,
-      )
+      const res = await apilib.like(this.rootStore, this.uri)
       runInAction(() => {
         this.likeCount++
         this.myState.like = res.uri
@@ -126,17 +122,13 @@ export class PostThreadViewPostModel implements GetPostThread.Post {
 
   async toggleRepost() {
     if (this.myState.repost) {
-      await apilib.unrepost(this.rootStore.api, this.myState.repost)
+      await apilib.unrepost(this.rootStore, this.myState.repost)
       runInAction(() => {
         this.repostCount--
         this.myState.repost = undefined
       })
     } else {
-      const res = await apilib.repost(
-        this.rootStore.api,
-        'did:test:alice',
-        this.uri,
-      )
+      const res = await apilib.repost(this.rootStore, this.uri)
       runInAction(() => {
         this.repostCount++
         this.myState.repost = res.uri
diff --git a/src/state/models/profile-view.ts b/src/state/models/profile-view.ts
index e7685482e..a7b8a7c7f 100644
--- a/src/state/models/profile-view.ts
+++ b/src/state/models/profile-view.ts
@@ -74,17 +74,13 @@ export class ProfileViewModel {
       throw new Error('Not logged in')
     }
     if (this.myState.follow) {
-      await apilib.unfollow(this.rootStore.api, this.myState.follow)
+      await apilib.unfollow(this.rootStore, this.myState.follow)
       runInAction(() => {
         this.followersCount--
         this.myState.follow = undefined
       })
     } else {
-      const res = await apilib.follow(
-        this.rootStore.api,
-        this.rootStore.me.did,
-        this.did,
-      )
+      const res = await apilib.follow(this.rootStore, this.did)
       runInAction(() => {
         this.followersCount++
         this.myState.follow = res.uri