{
- if (!ref.current) return;
- switch (e.code) {
- case 'ArrowUp':
- case 'ArrowLeft': {
- e.preventDefault();
- const prevIndex = Math.max(selectedIndex - 1, 0);
- setSelectedIndex(prevIndex);
- ref.current.scrollToIndex(prevIndex, {
- align: 'center',
- smooth: true,
- });
- break;
+
+ {
+ if (!ref.current) return;
+ switch (e.code) {
+ case 'ArrowUp':
+ case 'ArrowLeft': {
+ e.preventDefault();
+ const prevIndex = Math.max(selectedIndex - 1, 0);
+ setSelectedIndex(prevIndex);
+ ref.current.scrollToIndex(prevIndex, {
+ align: 'center',
+ smooth: true,
+ });
+ break;
+ }
+ case 'ArrowDown':
+ case 'ArrowRight': {
+ e.preventDefault();
+ const nextIndex = Math.min(selectedIndex + 1, data.length - 1);
+ setSelectedIndex(nextIndex);
+ ref.current.scrollToIndex(nextIndex, {
+ align: 'center',
+ smooth: true,
+ });
+ break;
+ }
+ default:
+ break;
}
- case 'ArrowDown':
- case 'ArrowRight': {
- e.preventDefault();
- const nextIndex = Math.min(selectedIndex + 1, data.length - 1);
- setSelectedIndex(nextIndex);
- ref.current.scrollToIndex(nextIndex, {
- align: 'center',
- smooth: true,
- });
- break;
- }
- default:
- break;
- }
- }}
- >
- {data.map((widget) => renderItem(widget))}
-
-
+ }}
+ >
+ {data.map((widget) => renderItem(widget))}
+
+
+
);
}
diff --git a/src/libs/ark/ark.ts b/src/libs/ark/ark.ts
index 689ce8c8..a7562043 100644
--- a/src/libs/ark/ark.ts
+++ b/src/libs/ark/ark.ts
@@ -43,6 +43,7 @@ export class Ark {
readonly platform: Platform | null;
readonly settings: {
autoupdate: boolean;
+ bunker: boolean;
outbox: boolean;
media: boolean;
hashtag: boolean;
@@ -53,6 +54,7 @@ export class Ark {
this.platform = platform;
this.settings = {
autoupdate: false,
+ bunker: false,
outbox: false,
media: true,
hashtag: true,
@@ -100,7 +102,7 @@ export class Ark {
const bunker = new NDK({
explicitRelayUrls: ['wss://relay.nsecbunker.com', 'wss://nostr.vulpem.com'],
});
- await bunker.connect();
+ await bunker.connect(3000);
const remoteSigner = new NDKNip46Signer(bunker, this.account.pubkey, localSigner);
await remoteSigner.blockUntilReady();
@@ -134,11 +136,14 @@ export class Ark {
}
public async init() {
- const outboxSetting = await this.getSettingValue('outbox');
- const bunkerSetting = await this.getSettingValue('nsecbunker');
-
- const bunker = !!parseInt(bunkerSetting);
- const enableOutboxModel = !!parseInt(outboxSetting);
+ const settings = await this.getAllSettings();
+ for (const item of settings) {
+ if (item.key === 'nsecbunker') this.settings.bunker = !!parseInt(item.value);
+ if (item.key === 'outbox') this.settings.outbox = !!parseInt(item.value);
+ if (item.key === 'media') this.settings.media = !!parseInt(item.value);
+ if (item.key === 'hashtag') this.settings.hashtag = !!parseInt(item.value);
+ if (item.key === 'autoupdate') this.settings.autoupdate = !!parseInt(item.value);
+ }
const explicitRelayUrls = normalizeRelayUrlSet([
'wss://relay.damus.io',
@@ -159,7 +164,7 @@ export class Ark {
explicitRelayUrls,
outboxRelayUrls,
blacklistRelayUrls,
- enableOutboxModel,
+ enableOutboxModel: this.settings.outbox,
autoConnectUserRelays: true,
autoFetchUserMutelist: true,
// clientName: 'Lume',
@@ -167,11 +172,11 @@ export class Ark {
});
// add signer if exist
- const signer = await this.#initNostrSigner({ nsecbunker: bunker });
+ const signer = await this.#initNostrSigner({ nsecbunker: this.settings.bunker });
if (signer) ndk.signer = signer;
// connect
- await ndk.connect();
+ await ndk.connect(5000);
const fetcher = NostrFetcher.withCustomPool(ndkAdapter(ndk));
// update account's metadata
@@ -356,7 +361,7 @@ export class Ark {
const results: { key: string; value: string }[] = await this.#storage.select(
'SELECT * FROM settings ORDER BY id DESC;'
);
- if (results.length < 1) return null;
+ if (results.length < 1) return [];
return results;
}
diff --git a/src/libs/ark/provider.tsx b/src/libs/ark/provider.tsx
index 087a2b7a..9ab4eb89 100644
--- a/src/libs/ark/provider.tsx
+++ b/src/libs/ark/provider.tsx
@@ -1,5 +1,3 @@
-import { NDKKind } from '@nostr-dev-kit/ndk';
-import { useQueryClient } from '@tanstack/react-query';
import { ask } from '@tauri-apps/plugin-dialog';
import { platform } from '@tauri-apps/plugin-os';
import { relaunch } from '@tauri-apps/plugin-process';
@@ -9,7 +7,7 @@ import Markdown from 'markdown-to-jsx';
import { PropsWithChildren, createContext, useContext, useEffect, useState } from 'react';
import { Ark } from '@libs/ark';
import { LoaderIcon } from '@shared/icons';
-import { FETCH_LIMIT, QUOTES } from '@utils/constants';
+import { QUOTES } from '@utils/constants';
const ArkContext = createContext(undefined);
@@ -17,8 +15,6 @@ const ArkProvider = ({ children }: PropsWithChildren