From b86216f7c26963231e65709aa55878cb92c42c05 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 17 Oct 2024 17:14:12 +0300 Subject: [PATCH] async resumeSession --- src/background/messages/block.ts | 2 +- src/background/messages/follow.ts | 2 +- src/background/messages/searchUser.ts | 2 +- src/background/messages/unblock.ts | 2 +- src/background/messages/unfollow.ts | 2 +- src/lib/bskyClient.ts | 6 ++++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/background/messages/block.ts b/src/background/messages/block.ts index e951d0d..52e2988 100644 --- a/src/background/messages/block.ts +++ b/src/background/messages/block.ts @@ -3,7 +3,7 @@ import { BskyClient } from "~lib/bskyClient"; const handler: PlasmoMessaging.MessageHandler = async (req, res) => { const { session, subjectDid } = req.body; - const client = BskyClient.createAgentFromSession(session); + const client = await BskyClient.createAgentFromSession(session); try { res.send({ diff --git a/src/background/messages/follow.ts b/src/background/messages/follow.ts index 71eb913..c749fc8 100644 --- a/src/background/messages/follow.ts +++ b/src/background/messages/follow.ts @@ -3,7 +3,7 @@ import { BskyClient } from "~lib/bskyClient"; const handler: PlasmoMessaging.MessageHandler = async (req, res) => { const { session, subjectDid } = req.body; - const client = BskyClient.createAgentFromSession(session); + const client = await BskyClient.createAgentFromSession(session); try { res.send({ diff --git a/src/background/messages/searchUser.ts b/src/background/messages/searchUser.ts index a5d7a55..d374593 100644 --- a/src/background/messages/searchUser.ts +++ b/src/background/messages/searchUser.ts @@ -3,7 +3,7 @@ import { BskyClient } from "~lib/bskyClient"; const handler: PlasmoMessaging.MessageHandler = async (req, res) => { const { session, term, limit } = req.body; - const client = BskyClient.createAgentFromSession(session); + const client = await BskyClient.createAgentFromSession(session); try { res.send({ diff --git a/src/background/messages/unblock.ts b/src/background/messages/unblock.ts index 7fd57a0..2848aaa 100644 --- a/src/background/messages/unblock.ts +++ b/src/background/messages/unblock.ts @@ -3,7 +3,7 @@ import { BskyClient } from "~lib/bskyClient"; const handler: PlasmoMessaging.MessageHandler = async (req, res) => { const { session, blockUri } = req.body; - const client = BskyClient.createAgentFromSession(session); + const client = await BskyClient.createAgentFromSession(session); try { res.send({ diff --git a/src/background/messages/unfollow.ts b/src/background/messages/unfollow.ts index e28894e..c553f52 100644 --- a/src/background/messages/unfollow.ts +++ b/src/background/messages/unfollow.ts @@ -3,7 +3,7 @@ import { BskyClient } from "~lib/bskyClient"; const handler: PlasmoMessaging.MessageHandler = async (req, res) => { const { session, followUri } = req.body; - const client = BskyClient.createAgentFromSession(session); + const client = await BskyClient.createAgentFromSession(session); try { res.send({ diff --git a/src/lib/bskyClient.ts b/src/lib/bskyClient.ts index 17254fa..111e4f1 100644 --- a/src/lib/bskyClient.ts +++ b/src/lib/bskyClient.ts @@ -27,12 +27,14 @@ export class BskyClient { }); } - public static createAgentFromSession(session: AtpSessionData): BskyClient { + public static async createAgentFromSession( + session: AtpSessionData, + ): Promise { if (clientCache.has(session.did)) { return clientCache.get(session.did); } const client = new BskyClient(); - client.agent.resumeSession(session); + await client.agent.resumeSession(session); client.me = { did: session.did, handle: session.handle,