From e5b3c9c9a09d2b0c05d08db092968bfb0a99ece2 Mon Sep 17 00:00:00 2001 From: Siddharth Singh Date: Fri, 2 Aug 2024 17:06:41 +0530 Subject: [PATCH 1/3] nostr: allow view in external viewer links to appear on all posts --- src/components/status-action-bar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/status-action-bar.tsx b/src/components/status-action-bar.tsx index f4005a7b2..79471459b 100644 --- a/src/components/status-action-bar.tsx +++ b/src/components/status-action-bar.tsx @@ -430,7 +430,7 @@ const StatusActionBar: React.FC = ({ } } - if (features.federating && !account.local) { + if (features.federating) { const externalNostrUrl: string | undefined = status.ditto?.get('external_url'); const { hostname: domain } = new URL(externalNostrUrl || status.uri); From c073278167c31caae30732f2ca1e50ec600de0cf Mon Sep 17 00:00:00 2001 From: Siddharth Singh Date: Fri, 2 Aug 2024 23:04:25 +0530 Subject: [PATCH 2/3] (hopefully) fix multiple accounts issue --- src/actions/nostr.ts | 4 +++- src/contexts/nostr-context.tsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/actions/nostr.ts b/src/actions/nostr.ts index 87d0d86f7..86e24d887 100644 --- a/src/actions/nostr.ts +++ b/src/actions/nostr.ts @@ -27,6 +27,8 @@ function logInNostr(pubkey: string) { secret, })); + dispatch(setNostrPubkey(undefined)); + const { access_token } = dispatch(authLoggedIn(token)); return await dispatch(verifyCredentials(access_token as string)); }; @@ -43,7 +45,7 @@ function nostrExtensionLogIn() { }; } -function setNostrPubkey(pubkey: string) { +function setNostrPubkey(pubkey: string | undefined) { return { type: NOSTR_PUBKEY_SET, pubkey, diff --git a/src/contexts/nostr-context.tsx b/src/contexts/nostr-context.tsx index a652e82c1..92bc9095b 100644 --- a/src/contexts/nostr-context.tsx +++ b/src/contexts/nostr-context.tsx @@ -28,7 +28,7 @@ export const NostrProvider: React.FC = ({ children }) => { const { account } = useOwnAccount(); const url = instance.nostr?.relay; - const accountPubkey = useAppSelector((state) => account?.nostr.pubkey ?? state.meta.pubkey); + const accountPubkey = useAppSelector((state) => state.meta.pubkey ?? account?.nostr.pubkey); const signer = useMemo( () => (accountPubkey ? NKeys.get(accountPubkey) : undefined) ?? window.nostr, From 612d9b67428b18597c84da465c049ff262a5f773 Mon Sep 17 00:00:00 2001 From: Siddharth Singh Date: Fri, 2 Aug 2024 19:45:01 +0000 Subject: [PATCH 3/3] Fix code to work properly on both mastodon and Ditto --- src/components/status-action-bar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/status-action-bar.tsx b/src/components/status-action-bar.tsx index 79471459b..ad6376cac 100644 --- a/src/components/status-action-bar.tsx +++ b/src/components/status-action-bar.tsx @@ -430,7 +430,7 @@ const StatusActionBar: React.FC = ({ } } - if (features.federating) { + if (features.federating && (status.ditto?.get('external_url') || !account.local)) { const externalNostrUrl: string | undefined = status.ditto?.get('external_url'); const { hostname: domain } = new URL(externalNostrUrl || status.uri);