From aa4c448999518d87add29666abdbca9a61d66441 Mon Sep 17 00:00:00 2001 From: k00b Date: Tue, 19 Nov 2024 14:58:48 -0600 Subject: [PATCH 1/3] fix account switch disconnect --- components/use-indexeddb.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/use-indexeddb.js b/components/use-indexeddb.js index eac828725..0afeeeeb5 100644 --- a/components/use-indexeddb.js +++ b/components/use-indexeddb.js @@ -27,12 +27,17 @@ function useIndexedDB ({ dbName, storeName, options = DEFAULT_OPTIONS, indices = db.transaction(storeName) while (operationQueue.current.length > 0) { const operation = operationQueue.current.shift() - operation(db) + // if the db is the same as the one we're processing, run the operation + // else, we'll just clear the operation queue + // XXX this is a consquence of using a ref to store the queue and should be fixed + if (dbName === db.name) { + operation(db) + } } } catch (error) { handleError(error) } - }, [storeName, handleError, operationQueue]) + }, [dbName, storeName, handleError, operationQueue]) useEffect(() => { let isMounted = true From f3cc0f9e1daef4681209106dee19bac105f57f5f Mon Sep 17 00:00:00 2001 From: k00b Date: Tue, 19 Nov 2024 15:38:27 -0600 Subject: [PATCH 2/3] make recv optional --- .../20241119210957_optional_recv/migration.sql | 11 +++++++++++ prisma/schema.prisma | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 prisma/migrations/20241119210957_optional_recv/migration.sql diff --git a/prisma/migrations/20241119210957_optional_recv/migration.sql b/prisma/migrations/20241119210957_optional_recv/migration.sql new file mode 100644 index 000000000..55cf88ecd --- /dev/null +++ b/prisma/migrations/20241119210957_optional_recv/migration.sql @@ -0,0 +1,11 @@ +-- AlterTable +ALTER TABLE "WalletBlink" ALTER COLUMN "apiKeyRecv" DROP NOT NULL; + +-- AlterTable +ALTER TABLE "WalletLNbits" ALTER COLUMN "invoiceKey" DROP NOT NULL; + +-- AlterTable +ALTER TABLE "WalletNWC" ALTER COLUMN "nwcUrlRecv" DROP NOT NULL; + +-- AlterTable +ALTER TABLE "WalletPhoenixd" ALTER COLUMN "secondaryPassword" DROP NOT NULL; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index dbe3d44e4..83a68c70b 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -289,7 +289,7 @@ model WalletLNbits { createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @default(now()) @updatedAt @map("updated_at") url String - invoiceKey String + invoiceKey String? } model WalletNWC { @@ -298,7 +298,7 @@ model WalletNWC { wallet Wallet @relation(fields: [walletId], references: [id], onDelete: Cascade) createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @default(now()) @updatedAt @map("updated_at") - nwcUrlRecv String + nwcUrlRecv String? } model WalletBlink { @@ -307,7 +307,7 @@ model WalletBlink { wallet Wallet @relation(fields: [walletId], references: [id], onDelete: Cascade) createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @default(now()) @updatedAt @map("updated_at") - apiKeyRecv String + apiKeyRecv String? currencyRecv String? } @@ -318,7 +318,7 @@ model WalletPhoenixd { createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @default(now()) @updatedAt @map("updated_at") url String - secondaryPassword String + secondaryPassword String? } model Mute { From 66ec5d5da89e2d8a9ab44b377b4e92f4a51063c1 Mon Sep 17 00:00:00 2001 From: k00b Date: Tue, 19 Nov 2024 15:46:11 -0600 Subject: [PATCH 3/3] dark/light mode images on wallet pages --- pages/settings/wallets/[wallet].js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pages/settings/wallets/[wallet].js b/pages/settings/wallets/[wallet].js index cbaa01730..f69e93d53 100644 --- a/pages/settings/wallets/[wallet].js +++ b/pages/settings/wallets/[wallet].js @@ -13,11 +13,12 @@ import { canReceive, canSend, isConfigured } from '@/wallets/common' import { SSR } from '@/lib/constants' import WalletButtonBar from '@/components/wallet-buttonbar' import { useWalletConfigurator } from '@/wallets/config' -import { useCallback, useMemo } from 'react' +import { useCallback, useEffect, useMemo, useState } from 'react' import { useMe } from '@/components/me' import validateWallet from '@/wallets/validate' import { ValidationError } from 'yup' import { useFormikContext } from 'formik' +import useDarkMode from '@/components/dark-mode' export const getServerSideProps = getGetServerSideProps({ authRequired: true }) @@ -28,6 +29,8 @@ export default function WalletSettings () { const wallet = useWallet(name) const { me } = useMe() const { save, detach } = useWalletConfigurator(wallet) + const [dark] = useDarkMode() + const [imgSrc, setImgSrc] = useState(wallet?.def.card?.image?.src) const initial = useMemo(() => { const initial = wallet?.def.fields.reduce((acc, field) => { @@ -69,12 +72,16 @@ export default function WalletSettings () { const { card: { image, title, subtitle } } = wallet?.def || { card: {} } + useEffect(() => { + if (!imgSrc) return + // wallet.png <-> wallet-dark.png + setImgSrc(dark ? image?.src.replace(/\.([a-z]{3})$/, '-dark.$1') : image?.src) + }, [dark]) + return ( {image - ? typeof image === 'object' - ? {title} - : {title} + ? {title} :

{title}

}
{subtitle}