From 75cca62612154c9504bf173932a72b8a83177a41 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Fri, 8 Dec 2023 13:38:20 -0600 Subject: [PATCH 1/7] add preset icon --- screenshots/icon.svg | 251 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 screenshots/icon.svg diff --git a/screenshots/icon.svg b/screenshots/icon.svg new file mode 100644 index 000000000..515b5f592 --- /dev/null +++ b/screenshots/icon.svg @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 85af49073876bc3ccc8d78365b9fddf8e6fd1b5b Mon Sep 17 00:00:00 2001 From: hzrd149 <8001706+hzrd149@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:39:53 -0600 Subject: [PATCH 2/7] Add icon to readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index bbc602d3b..1568d0087 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +

+ Project Logo +

+ # noStrudel > NOTE: This client is still in development and will have bugs From 48fd8e14d289a3b5ff276466ee33cad3526b8eaf Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Sat, 9 Dec 2023 07:21:57 -0600 Subject: [PATCH 3/7] tweaks --- dockerfile | 6 ++++-- src/components/layout/account-switcher.tsx | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dockerfile b/dockerfile index 07b51c58a..bc325c3f1 100644 --- a/dockerfile +++ b/dockerfile @@ -1,11 +1,13 @@ # syntax=docker/dockerfile:1 -FROM node:20 +FROM node:20 as builder + WORKDIR /app COPY . /app/ + ENV VITE_COMMIT_HASH="" ENV VITE_APP_VERSION="custom" RUN yarn install && yarn build FROM nginx:stable-alpine-slim EXPOSE 80 -COPY --from=0 /app/dist /usr/share/nginx/html +COPY --from=builder /app/dist /usr/share/nginx/html diff --git a/src/components/layout/account-switcher.tsx b/src/components/layout/account-switcher.tsx index 6e074d848..f9b78048e 100644 --- a/src/components/layout/account-switcher.tsx +++ b/src/components/layout/account-switcher.tsx @@ -24,8 +24,10 @@ function AccountItem({ account, onClick }: { account: Account; onClick?: () => v - {getUserDisplayName(metadata, pubkey)} - + + {getUserDisplayName(metadata, pubkey)} + + } From faa763087fb19dc7878673175cee9267dec30295 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Sat, 9 Dec 2023 07:25:26 -0600 Subject: [PATCH 4/7] fix share link on user profiles --- .../common-menu-items/copy-embed-code.tsx | 2 +- .../common-menu-items/copy-share-link.tsx | 2 +- src/views/user/components/user-profile-menu.tsx | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/common-menu-items/copy-embed-code.tsx b/src/components/common-menu-items/copy-embed-code.tsx index fad23f13a..4646255a7 100644 --- a/src/components/common-menu-items/copy-embed-code.tsx +++ b/src/components/common-menu-items/copy-embed-code.tsx @@ -10,7 +10,7 @@ export default function CopyEmbedCodeMenuItem({ event }: { event: NostrEvent }) return ( address && ( window.navigator.clipboard.writeText("nostr:" + address)} icon={}> - Copy Embed Code + Copy embed code ) ); diff --git a/src/components/common-menu-items/copy-share-link.tsx b/src/components/common-menu-items/copy-share-link.tsx index 68219f5c1..ef3b44c24 100644 --- a/src/components/common-menu-items/copy-share-link.tsx +++ b/src/components/common-menu-items/copy-share-link.tsx @@ -13,7 +13,7 @@ export default function CopyShareLinkMenuItem({ event }: { event: NostrEvent }) onClick={() => window.navigator.clipboard.writeText("https://njump.me/" + address)} icon={} > - Copy Share Link + Copy share link ) ); diff --git a/src/views/user/components/user-profile-menu.tsx b/src/views/user/components/user-profile-menu.tsx index 0e23e6751..539d6eef3 100644 --- a/src/views/user/components/user-profile-menu.tsx +++ b/src/views/user/components/user-profile-menu.tsx @@ -1,7 +1,6 @@ import { MenuItem, useDisclosure } from "@chakra-ui/react"; import { Link as RouterLink } from "react-router-dom"; import { nip19 } from "nostr-tools"; -import { useCopyToClipboard } from "react-use"; import { CustomMenuIconButton, MenuIconButtonProps } from "../../../components/menu-icon-button"; import { @@ -13,6 +12,7 @@ import { RelayIcon, SpyIcon, UnmuteIcon, + ShareIcon, } from "../../../components/icons"; import accountService from "../../../services/account"; import { useUserMetadata } from "../../../hooks/use-user-metadata"; @@ -38,13 +38,11 @@ export const UserProfileMenu = ({ const sharableId = useSharableProfileId(pubkey); const { isMuted, mute, unmute } = useUserMuteFunctions(pubkey); - const [_clipboardState, copyToClipboard] = useCopyToClipboard(); - const loginAsUser = () => { const readRelays = userRelays.filter((r) => r.mode === RelayMode.READ).map((r) => r.url) ?? []; if (!accountService.hasAccount(pubkey)) { accountService.addAccount({ - type: 'pubkey', + type: "pubkey", pubkey, relays: readRelays, readonly: true, @@ -70,9 +68,18 @@ export const UserProfileMenu = ({ } onClick={() => loginAsUser()}> Login as {truncatedId(getUserDisplayName(metadata, pubkey))} - copyToClipboard("nostr:" + sharableId)} icon={}> + window.navigator.clipboard.writeText("https://njump.me/" + sharableId)} + icon={} + > Copy share link + window.navigator.clipboard.writeText("nostr:" + sharableId)} + icon={} + > + Copy Embed Code + }> View Raw From f7a913ca608036eb42155d2d2954f2961224d2d1 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Sun, 10 Dec 2023 07:02:18 -0600 Subject: [PATCH 5/7] fix database settings on http --- src/views/settings/database-settings.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/settings/database-settings.tsx b/src/views/settings/database-settings.tsx index dea5659ee..3072f4e9c 100644 --- a/src/views/settings/database-settings.tsx +++ b/src/views/settings/database-settings.tsx @@ -25,7 +25,7 @@ function niceBytes(x: number) { } function DatabaseStats() { - const { value: estimatedStorage } = useAsync(() => window.navigator?.storage?.estimate?.(), []); + const { value: estimatedStorage } = useAsync(async () => await window.navigator?.storage?.estimate?.(), []); const { value: replaceableEventCount } = useAsync(async () => { const keys = await db.getAllKeys("replaceableEvents"); From 7cbaa2edf613c7acf751b378e957b600fdac3e12 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Sun, 10 Dec 2023 07:16:12 -0600 Subject: [PATCH 6/7] fix clipboard on http --- .../common-menu-items/copy-share-link.tsx | 9 +++++++-- src/components/copy-icon-button.tsx | 5 +++-- src/components/version-button.tsx | 5 +++-- src/services/amber-signer.ts | 4 ++-- .../community/components/community-post-menu.tsx | 9 +++++++-- src/views/search/index.tsx | 2 +- src/views/user/components/user-profile-menu.tsx | 15 ++++++++++++--- 7 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/components/common-menu-items/copy-share-link.tsx b/src/components/common-menu-items/copy-share-link.tsx index ef3b44c24..bc902761b 100644 --- a/src/components/common-menu-items/copy-share-link.tsx +++ b/src/components/common-menu-items/copy-share-link.tsx @@ -1,16 +1,21 @@ -import { MenuItem } from "@chakra-ui/react"; +import { MenuItem, useToast } from "@chakra-ui/react"; import { NostrEvent } from "../../types/nostr-event"; import { getSharableEventAddress } from "../../helpers/nip19"; import { ShareIcon } from "../icons"; export default function CopyShareLinkMenuItem({ event }: { event: NostrEvent }) { + const toast = useToast(); const address = getSharableEventAddress(event); return ( address && ( window.navigator.clipboard.writeText("https://njump.me/" + address)} + onClick={() => { + const text = "https://njump.me/" + address; + if (navigator.clipboard) navigator.clipboard.writeText(text); + else toast({ description: text, isClosable: true, duration: null }); + }} icon={} > Copy share link diff --git a/src/components/copy-icon-button.tsx b/src/components/copy-icon-button.tsx index 11113b385..ccbbb4524 100644 --- a/src/components/copy-icon-button.tsx +++ b/src/components/copy-icon-button.tsx @@ -1,9 +1,10 @@ import { useState } from "react"; -import { IconButton, IconButtonProps } from "@chakra-ui/react"; +import { IconButton, IconButtonProps, useToast } from "@chakra-ui/react"; import { CheckIcon, CopyToClipboardIcon } from "./icons"; export const CopyIconButton = ({ text, ...props }: { text?: string } & Omit) => { + const toast = useToast(); const [copied, setCopied] = useState(false); return ( @@ -14,7 +15,7 @@ export const CopyIconButton = ({ text, ...props }: { text?: string } & Omit setCopied(false), 2000); - } + } else toast({ description: text, isClosable: true, duration: null }); }} {...props} /> diff --git a/src/components/version-button.tsx b/src/components/version-button.tsx index ef119ae37..b38c06b4a 100644 --- a/src/components/version-button.tsx +++ b/src/components/version-button.tsx @@ -1,8 +1,9 @@ -import { Button, ButtonProps } from "@chakra-ui/react"; +import { Button, ButtonProps, useToast } from "@chakra-ui/react"; import { CheckIcon, CopyToClipboardIcon } from "./icons"; import { useState } from "react"; export default function VersionButton({ ...props }: Omit) { + const toast = useToast(); const [copied, setCopied] = useState(false); const version = [import.meta.env.VITE_APP_VERSION, import.meta.env.VITE_COMMIT_HASH].filter(Boolean).join("-"); @@ -18,7 +19,7 @@ export default function VersionButton({ ...props }: Omit setCopied(false), 2000); - } + } else toast({ description: version, isClosable: true, duration: null }); }} {...props} > diff --git a/src/services/amber-signer.ts b/src/services/amber-signer.ts index d92de22cc..8b4e85c4f 100644 --- a/src/services/amber-signer.ts +++ b/src/services/amber-signer.ts @@ -34,7 +34,7 @@ function rejectPending() { function onVisibilityChange() { if (document.visibilityState === "visible") { - if (!pendingRequest) return; + if (!pendingRequest || !navigator.clipboard) return; // read the result from the clipboard setTimeout(() => { @@ -92,7 +92,7 @@ async function nip04Decrypt(pubkey: string, data: string): Promise { } const amberSignerService = { - supported: navigator.userAgent.includes("Android"), + supported: navigator.userAgent.includes("Android") && navigator.clipboard, getPublicKey, signEvent, nip04Encrypt, diff --git a/src/views/community/components/community-post-menu.tsx b/src/views/community/components/community-post-menu.tsx index f16f5e1b9..abb1e61c3 100644 --- a/src/views/community/components/community-post-menu.tsx +++ b/src/views/community/components/community-post-menu.tsx @@ -1,4 +1,4 @@ -import { MenuItem, useDisclosure } from "@chakra-ui/react"; +import { MenuItem, useDisclosure, useToast } from "@chakra-ui/react"; import { nip19 } from "nostr-tools"; import { CustomMenuIconButton, MenuIconButtonProps } from "../../../components/menu-icon-button"; @@ -14,6 +14,7 @@ export default function CommunityPostMenu({ approvals, ...props }: Omit & { event: NostrEvent; approvals: NostrEvent[] }) { + const toast = useToast(); const debugModal = useDisclosure(); return ( @@ -22,7 +23,11 @@ export default function CommunityPostMenu({ window.navigator.clipboard.writeText(nip19.noteEncode(event.id))} + onClick={() => { + const text = nip19.noteEncode(event.id); + if (navigator.clipboard) navigator.clipboard.writeText(text); + else toast({ description: text, isClosable: true, duration: null }); + }} icon={} > Copy Note ID diff --git a/src/views/search/index.tsx b/src/views/search/index.tsx index 1a7182c36..c12dd1e0b 100644 --- a/src/views/search/index.tsx +++ b/src/views/search/index.tsx @@ -98,7 +98,7 @@ export function SearchPage() { } aria-label="Qr Scanner" /> - {!!navigator.clipboard.readText && ( + {!!navigator.clipboard?.readText && ( } aria-label="Read clipboard" /> )} setSearchInput(e.target.value)} /> diff --git a/src/views/user/components/user-profile-menu.tsx b/src/views/user/components/user-profile-menu.tsx index 539d6eef3..1b3756ae6 100644 --- a/src/views/user/components/user-profile-menu.tsx +++ b/src/views/user/components/user-profile-menu.tsx @@ -1,4 +1,4 @@ -import { MenuItem, useDisclosure } from "@chakra-ui/react"; +import { MenuItem, useDisclosure, useToast } from "@chakra-ui/react"; import { Link as RouterLink } from "react-router-dom"; import { nip19 } from "nostr-tools"; @@ -31,6 +31,7 @@ export const UserProfileMenu = ({ showRelaySelectionModal, ...props }: { pubkey: string; showRelaySelectionModal?: () => void } & Omit) => { + const toast = useToast(); const account = useCurrentAccount(); const metadata = useUserMetadata(pubkey); const userRelays = useUserRelays(pubkey); @@ -69,13 +70,21 @@ export const UserProfileMenu = ({ Login as {truncatedId(getUserDisplayName(metadata, pubkey))} window.navigator.clipboard.writeText("https://njump.me/" + sharableId)} + onClick={() => { + const text = "https://njump.me/" + sharableId; + if (navigator.clipboard) navigator.clipboard?.writeText(text); + else toast({ description: text, isClosable: true, duration: null }); + }} icon={} > Copy share link window.navigator.clipboard.writeText("nostr:" + sharableId)} + onClick={() => { + const text = "nostr:" + sharableId; + if (navigator.clipboard) navigator.clipboard?.writeText(text); + else toast({ description: text, isClosable: true, duration: null }); + }} icon={} > Copy Embed Code From feec68803f62ea1b2a7bbcab60cbace72c512953 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Sun, 10 Dec 2023 07:16:43 -0600 Subject: [PATCH 7/7] add changeset --- .changeset/curvy-bears-smell.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/curvy-bears-smell.md diff --git a/.changeset/curvy-bears-smell.md b/.changeset/curvy-bears-smell.md new file mode 100644 index 000000000..fb1efc196 --- /dev/null +++ b/.changeset/curvy-bears-smell.md @@ -0,0 +1,5 @@ +--- +"nostrudel": patch +--- + +Fix storage and clipboard use on http connection