mirror of
https://github.com/snachodog/tok-to-insta-follower-bridge.git
synced 2025-04-10 14:11:22 -06:00
refactor: use bskyClient
This commit is contained in:
parent
f637e48f3a
commit
93b4d2f8ae
@ -1,35 +0,0 @@
|
||||
import type { PlasmoMessaging } from "@plasmohq/messaging";
|
||||
import { BskyClient } from "~lib/bskyClient";
|
||||
import { STORAGE_KEYS } from "~lib/constants";
|
||||
|
||||
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
|
||||
const { name, description, userDids } = req.body;
|
||||
|
||||
const storage = await chrome.storage.local.get(
|
||||
STORAGE_KEYS.BSKY_CLIENT_SESSION,
|
||||
);
|
||||
const session = storage[STORAGE_KEYS.BSKY_CLIENT_SESSION];
|
||||
|
||||
if (!session || !session.did) {
|
||||
res.send({
|
||||
error: {
|
||||
message: "Invalid session data",
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const client = await BskyClient.createAgentFromSession(session);
|
||||
await client.createListAndAddUsers({ name, description, userDids });
|
||||
res.send({ success: true });
|
||||
} catch (e) {
|
||||
res.send({
|
||||
error: {
|
||||
message: e.message,
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default handler;
|
@ -131,13 +131,10 @@ export const useBskyUserManager = () => {
|
||||
|
||||
if (actionMode === ACTION_MODE.IMPORT_LIST) {
|
||||
const userDids = filteredUsers.map((user) => user.did);
|
||||
await chrome.runtime.sendMessage({
|
||||
name: "createListAndAddUsers",
|
||||
body: {
|
||||
name: listName,
|
||||
description: "List imported via Sky Follower Bridge",
|
||||
userDids,
|
||||
},
|
||||
await bskyClient.current.createListAndAddUsers({
|
||||
name: listName,
|
||||
description: "List imported via Sky Follower Bridge",
|
||||
userDids,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user