wip: fully migrate to tauri v2
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
NDKUser,
|
||||
} from '@nostr-dev-kit/ndk';
|
||||
import { message, open } from '@tauri-apps/plugin-dialog';
|
||||
import { Body, fetch } from '@tauri-apps/plugin-http';
|
||||
import { fetch } from '@tauri-apps/plugin-http';
|
||||
import { LRUCache } from 'lru-cache';
|
||||
import { NostrEventExt } from 'nostr-fetch';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
@@ -18,7 +18,6 @@ import { useStorage } from '@libs/storage/provider';
|
||||
|
||||
import { useStronghold } from '@stores/stronghold';
|
||||
|
||||
import { createBlobFromFile } from '@utils/createBlobFromFile';
|
||||
import { nHoursAgo } from '@utils/date';
|
||||
import { getMultipleRandom } from '@utils/transform';
|
||||
import { NDKEventWithReplies, NostrBuildResponse } from '@utils/types';
|
||||
@@ -413,27 +412,19 @@ export function useNostr() {
|
||||
error: 'Cancelled',
|
||||
};
|
||||
} else {
|
||||
filepath = selected;
|
||||
filepath = selected.path;
|
||||
}
|
||||
}
|
||||
|
||||
const filename = filepath.split('/').pop();
|
||||
const filetype = filename.split('.').pop();
|
||||
const formData = new FormData();
|
||||
formData.append('file', filepath);
|
||||
|
||||
const fileData = await createBlobFromFile(filepath);
|
||||
const res: NostrBuildResponse = await fetch(
|
||||
'https://nostr.build/api/v2/upload/files',
|
||||
{
|
||||
method: 'POST',
|
||||
timeout: 30,
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
body: Body.form({
|
||||
fileData: {
|
||||
file: fileData,
|
||||
mime: `image/${filetype}`,
|
||||
fileName: filename,
|
||||
},
|
||||
}),
|
||||
body: formData,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api/tauri';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
|
||||
import { Opengraph } from '@utils/types';
|
||||
|
||||
|
||||
2
src/utils/types.d.ts
vendored
2
src/utils/types.d.ts
vendored
@@ -94,7 +94,7 @@ export interface NDKEventWithReplies extends NDKEvent {
|
||||
|
||||
export interface NostrBuildResponse extends Response {
|
||||
ok: boolean;
|
||||
data: {
|
||||
data?: {
|
||||
message: string;
|
||||
status: string;
|
||||
data: Array<{
|
||||
|
||||
Reference in New Issue
Block a user