diff options
author | Paul Frazee <pfrazee@gmail.com> | 2022-11-08 12:14:51 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2022-11-08 12:14:51 -0600 |
commit | 1fbc4cf1f2279cf4cf6804ff02616515e82d2a38 (patch) | |
tree | 0796e390ba5a04e5c46ea9a560809803252fda78 /src/state/lib/api.ts | |
parent | e650d98924051abfee40ff956f7348e2e47e7cd7 (diff) | |
download | voidsky-1fbc4cf1f2279cf4cf6804ff02616515e82d2a38.tar.zst |
Finish the upvote/downvote implementation
Diffstat (limited to 'src/state/lib/api.ts')
-rw-r--r-- | src/state/lib/api.ts | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/state/lib/api.ts b/src/state/lib/api.ts index 3d2d26a56..efaac5c7b 100644 --- a/src/state/lib/api.ts +++ b/src/state/lib/api.ts @@ -50,21 +50,45 @@ export async function post( ) } -export async function like(store: RootStoreModel, uri: string, cid: string) { - return await store.api.app.bsky.feed.like.create( +export async function upvote(store: RootStoreModel, uri: string, cid: string) { + return await store.api.app.bsky.feed.vote.create( {did: store.me.did || ''}, { subject: {uri, cid}, + direction: 'up', createdAt: new Date().toISOString(), }, ) } -export async function unlike(store: RootStoreModel, likeUri: string) { - const likeUrip = new AtUri(likeUri) - return await store.api.app.bsky.feed.like.delete({ - did: likeUrip.hostname, - rkey: likeUrip.rkey, +export async function unupvote(store: RootStoreModel, upvoteUri: string) { + const urip = new AtUri(upvoteUri) + return await store.api.app.bsky.feed.vote.delete({ + did: urip.hostname, + rkey: urip.rkey, + }) +} + +export async function downvote( + store: RootStoreModel, + uri: string, + cid: string, +) { + return await store.api.app.bsky.feed.vote.create( + {did: store.me.did || ''}, + { + subject: {uri, cid}, + direction: 'down', + createdAt: new Date().toISOString(), + }, + ) +} + +export async function undownvote(store: RootStoreModel, downvoteUri: string) { + const urip = new AtUri(downvoteUri) + return await store.api.app.bsky.feed.vote.delete({ + did: urip.hostname, + rkey: urip.rkey, }) } |