This commit is contained in:
2024-10-28 08:04:19 +07:00
parent 0518389f50
commit 9ba95301db
8 changed files with 27 additions and 13 deletions

View File

@@ -128,9 +128,9 @@ async setSigner(id: string) : Promise<Result<null, string>> {
else return { status: "error", error: e as any };
}
},
async getProfile(id: string) : Promise<Result<string, string>> {
async getProfile(id: string, cacheOnly: boolean) : Promise<Result<string, string>> {
try {
return { status: "ok", data: await TAURI_INVOKE("get_profile", { id }) };
return { status: "ok", data: await TAURI_INVOKE("get_profile", { id, cacheOnly }) };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };

View File

@@ -45,12 +45,12 @@ export function NoteRepost({
const list: Promise<MenuItem>[] = [];
for (const account of accounts) {
const res = await commands.getProfile(account);
const res = await commands.getProfile(account, true);
let name = "unknown";
if (res.status === "ok") {
const profile: Metadata = JSON.parse(res.data);
name = profile.display_name ?? profile.name ?? "unknown";
name = profile.display_name ?? profile.name ?? "anon";
}
list.push(

View File

@@ -199,12 +199,12 @@ function OpenLaunchpad() {
const list: Promise<MenuItem>[] = [];
for (const account of accounts) {
const res = await commands.getProfile(account);
const res = await commands.getProfile(account, true);
let name = "unknown";
if (res.status === "ok") {
const profile: Metadata = JSON.parse(res.data);
name = profile.display_name ?? profile.name ?? "unknown";
name = profile.display_name ?? profile.name ?? "anon";
}
list.push(

View File

@@ -104,12 +104,12 @@ function Screen() {
const list: Promise<MenuItem>[] = [];
for (const account of accounts) {
const res = await commands.getProfile(account);
const res = await commands.getProfile(account, true);
let name = "unknown";
if (res.status === "ok") {
const profile: Metadata = JSON.parse(res.data);
name = profile.display_name ?? profile.name ?? "unknown";
name = profile.display_name ?? profile.name ?? "anon";
}
list.push(

View File

@@ -3,7 +3,7 @@ import { createFileRoute } from "@tanstack/react-router";
export const Route = createFileRoute("/settings/$id/profile")({
beforeLoad: async ({ params }) => {
const res = await commands.getProfile(params.id);
const res = await commands.getProfile(params.id, true);
if (res.status === "ok") {
const profile: Profile = JSON.parse(res.data);

View File

@@ -31,12 +31,12 @@ function Screen() {
const list: Promise<MenuItem>[] = [];
for (const account of accounts) {
const res = await commands.getProfile(account);
const res = await commands.getProfile(account, true);
let name = "unknown";
if (res.status === "ok") {
const profile: Metadata = JSON.parse(res.data);
name = profile.display_name ?? profile.name ?? "unknown";
name = profile.display_name ?? profile.name ?? "anon";
}
list.push(

View File

@@ -26,7 +26,7 @@ export function useProfile(pubkey: string, embed?: string) {
}
}
const query = await commands.getProfile(normalizedId);
const query = await commands.getProfile(normalizedId, false);
if (query.status === "ok") {
return JSON.parse(query.data) as Metadata;