async resumeSession

This commit is contained in:
Samuel Newman 2024-10-17 17:14:12 +03:00
parent 1bd4b07c38
commit b86216f7c2
6 changed files with 9 additions and 7 deletions

View File

@ -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({

View File

@ -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({

View File

@ -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({

View File

@ -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({

View File

@ -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({

View File

@ -27,12 +27,14 @@ export class BskyClient {
});
}
public static createAgentFromSession(session: AtpSessionData): BskyClient {
public static async createAgentFromSession(
session: AtpSessionData,
): Promise<BskyClient> {
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,