mirror of
https://github.com/lumehq/lume.git
synced 2025-03-17 13:22:05 +01:00
update
This commit is contained in:
parent
0518389f50
commit
9ba95301db
@ -32,10 +32,24 @@ pub struct Mention {
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn get_profile(id: String, state: State<'_, Nostr>) -> Result<String, String> {
|
||||
pub async fn get_profile(
|
||||
id: String,
|
||||
cache_only: bool,
|
||||
state: State<'_, Nostr>,
|
||||
) -> Result<String, String> {
|
||||
let client = &state.client;
|
||||
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
||||
|
||||
if cache_only {
|
||||
let profile = client
|
||||
.database()
|
||||
.profile(public_key)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
return Ok(profile.metadata().as_json());
|
||||
};
|
||||
|
||||
let metadata = client
|
||||
.fetch_metadata(public_key, Some(Duration::from_secs(3)))
|
||||
.await
|
||||
|
@ -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 };
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user