🐛 fix id error

This commit is contained in:
kawamataryo 2024-02-11 20:31:35 +09:00
parent 74dc14022f
commit 2e8e22eda0
3 changed files with 13 additions and 12 deletions

View File

@ -44,7 +44,7 @@ const App = () => {
message: { message: {
name: (typeof MESSAGE_NAMES)[keyof typeof MESSAGE_NAMES]; name: (typeof MESSAGE_NAMES)[keyof typeof MESSAGE_NAMES];
body: { body: {
userId: string; identifier: string;
password: string; password: string;
}; };
}, },
@ -53,7 +53,7 @@ const App = () => {
) => { ) => {
if (Object.values(MESSAGE_NAMES).includes(message.name)) { if (Object.values(MESSAGE_NAMES).includes(message.name)) {
initialize({ initialize({
identifier: message.body.userId, identifier: message.body.identifier,
password: message.body.password, password: message.body.password,
messageName: message.name, messageName: message.name,
}) })

View File

@ -42,7 +42,7 @@ export class BskyClient {
}: BskyLoginParams): Promise<BskyClient> { }: BskyLoginParams): Promise<BskyClient> {
const client = new BskyClient(); const client = new BskyClient();
const { data } = await client.agent.login({ const { data } = await client.agent.login({
identifier: identifier.replace(/^@/, ""), // if identifier is a handle name, @ is not required identifier,
password, password,
}); });
client.me = { client.me = {

View File

@ -16,13 +16,13 @@ import {
function IndexPopup() { function IndexPopup() {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [userId, setUserId] = useState(""); const [identifier, setIdentifier] = useState("");
const [reloadCount, setReloadCount] = useState(0); const [reloadCount, setReloadCount] = useState(0);
const [message, setMessage] = useState<null | { const [message, setMessage] = useState<null | {
type: (typeof MESSAGE_TYPE)[keyof typeof MESSAGE_TYPE]; type: (typeof MESSAGE_TYPE)[keyof typeof MESSAGE_TYPE];
message: string; message: string;
}>(null); }>(null);
const isDisabled = !password || !userId || isLoading; const isDisabled = !password || !identifier || isLoading;
const isShowErrorMessage = message?.type === MESSAGE_TYPE.ERROR; const isShowErrorMessage = message?.type === MESSAGE_TYPE.ERROR;
const isShowSuccessMessage = message?.type === MESSAGE_TYPE.SUCCESS; const isShowSuccessMessage = message?.type === MESSAGE_TYPE.SUCCESS;
@ -41,7 +41,7 @@ function IndexPopup() {
const saveCredentialsToStorage = () => { const saveCredentialsToStorage = () => {
chrome.storage.local.set({ chrome.storage.local.set({
[STORAGE_KEYS.BSKY_PASSWORD]: password, [STORAGE_KEYS.BSKY_PASSWORD]: password,
[STORAGE_KEYS.BSKY_USER_ID]: userId, [STORAGE_KEYS.BSKY_USER_ID]: identifier,
}); });
}; };
@ -50,7 +50,7 @@ function IndexPopup() {
[STORAGE_KEYS.BSKY_PASSWORD, STORAGE_KEYS.BSKY_USER_ID], [STORAGE_KEYS.BSKY_PASSWORD, STORAGE_KEYS.BSKY_USER_ID],
(result) => { (result) => {
setPassword(result[STORAGE_KEYS.BSKY_PASSWORD] || ""); setPassword(result[STORAGE_KEYS.BSKY_PASSWORD] || "");
setUserId(result[STORAGE_KEYS.BSKY_USER_ID] || ""); setIdentifier(result[STORAGE_KEYS.BSKY_USER_ID] || "");
}, },
); );
}, []); }, []);
@ -91,13 +91,14 @@ function IndexPopup() {
setMessage(null); setMessage(null);
setIsLoading(true); setIsLoading(true);
const formattedIdentifier = (identifier.includes(".") ? identifier : `${identifier}.bsky.social`).replace(/^@/, "")
try { try {
const res: { hasError: boolean; message: string } = const res: { hasError: boolean; message: string } =
await sendToContentScript({ await sendToContentScript({
name: messageName, name: messageName,
body: { body: {
identifier: formattedIdentifier,
password, password,
userId,
}, },
}); });
if (res.hasError) { if (res.hasError) {
@ -155,7 +156,7 @@ function IndexPopup() {
Sky Follower Bridge Sky Follower Bridge
</h1> </h1>
<form onSubmit={searchBskyUser} className="mt-2"> <form onSubmit={searchBskyUser} className="mt-2">
<label className="join w-full" htmlFor="userId"> <label className="join w-full" htmlFor="identifier">
<span className="join-item btn btn-sm btn-active cursor-default"> <span className="join-item btn btn-sm btn-active cursor-default">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@ -174,10 +175,10 @@ function IndexPopup() {
</span> </span>
<input <input
type="text" type="text"
name="userId" name="identifier"
placeholder="@you.bsky.social" placeholder="@you.bsky.social"
value={userId} value={identifier}
onChange={(e) => setUserId(e.target.value)} onChange={(e) => setIdentifier(e.target.value)}
className="input input-bordered input-sm w-full max-w-xs join-item focus:outline-none" className="input input-bordered input-sm w-full max-w-xs join-item focus:outline-none"
/> />
</label> </label>