Skip to content

Commit

Permalink
Merge pull request #3286 from getAlby/revert-3283-allow-to-close-aler…
Browse files Browse the repository at this point in the history
…t-banner

Revert "feat: allow to close wallet update banner"
  • Loading branch information
pavanjoshi914 authored Dec 11, 2024
2 parents c78fdab + 894df34 commit 6f08fe9
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 60 deletions.
41 changes: 6 additions & 35 deletions src/app/components/Alert/index.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,22 @@
import { PopiconsXLine } from "@popicons/react";
import { useState } from "react";
import { classNames } from "~/app/utils";

type Props = {
type: "warn" | "info";
children: React.ReactNode;
showClose?: boolean;
onClose?: () => void; // Optional callback function
};

export default function Alert({
type,
children,
showClose = false,
onClose,
}: Props) {
const [isVisible, setIsVisible] = useState(true);

const handleClose = () => {
setIsVisible(false);
if (onClose) {
onClose(); // Invoke the callback function if provided
}
};

if (!isVisible) return null;

export default function Alert({ type, children }: Props) {
return (
<div
className={classNames(
"border rounded-md p-3 flex justify-between relative",
type === "warn" &&
"text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900 border-orange-100 dark:border-orange-900",
type === "info" &&
"border rounded-md p-3",
type == "warn" &&
"text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900 border-orange-100 dark:border-orange-900",
type == "info" &&
"text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900 border-blue-100 dark:border-blue-900"
)}
>
{showClose && (
<button
onClick={handleClose}
className="absolute right-2 top-2 text-gray-600 dark:text-neutral-400 hover:text-gray-700 dark:hover:text-neutral-300"
aria-label="Close alert"
>
<PopiconsXLine className="w-5 h-5" />
</button>
)}
<div className="pr-8">{children}</div>
{children}
</div>
);
}
16 changes: 2 additions & 14 deletions src/app/screens/Home/DefaultView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ const DefaultView: FC<Props> = (props) => {
const [isBlockedUrl, setIsBlockedUrl] = useState<boolean>(false);
const [currentAccount, setCurrentAccount] = useState<GetAccountRes>();
const [nostrPublicKey, setNostrPublicKey] = useState("");
const [seenSharedNodeBanner, setSeenSharedNodeBanner] =
useState<boolean>(false);

const { transactions, isLoadingTransactions, loadTransactions } =
useTransactions();
Expand Down Expand Up @@ -87,8 +85,6 @@ const DefaultView: FC<Props> = (props) => {
const userAccount = await api.getAccount();
const nostrPrivateKey = await api.nostr.getPrivateKey(userAccount.id);

setSeenSharedNodeBanner(userAccount.seenSharedNodeBanner);

setNostrPublicKey(
nostrPrivateKey ? await nostr.derivePublicKey(nostrPrivateKey) : ""
);
Expand Down Expand Up @@ -180,16 +176,8 @@ const DefaultView: FC<Props> = (props) => {
</Alert>
)}

{account?.sharedNode && !seenSharedNodeBanner && (
<Alert
type="info"
showClose
onClose={async () =>
await api.editAccount(account.id, {
seenSharedNodeBanner: true,
})
}
>
{account?.sharedNode && (
<Alert type="info">
<div className="flex items-center gap-2">
<div className="shrink-0">
<PopiconsCircleExclamationLine className="w-5 h-5" />
Expand Down
1 change: 0 additions & 1 deletion src/common/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export interface GetAccountRes extends Pick<Account, "id" | "name"> {
hasMnemonic: boolean;
isMnemonicBackupDone: boolean;
hasImportedNostrKey: boolean;
seenSharedNodeBanner: boolean;
bitcoinNetwork: BitcoinNetworkType;
useMnemonicForLnurlAuth: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ describe("account info", () => {
nostrEnabled: false,
liquidEnabled: false,
hasMnemonic: false,
seenSharedNodeBanner: false,
hasImportedNostrKey: true,
bitcoinNetwork: "bitcoin",
useMnemonicForLnurlAuth: false,
Expand Down Expand Up @@ -92,7 +91,6 @@ describe("account info", () => {
nostrEnabled: true,
liquidEnabled: true,
hasMnemonic: true,
seenSharedNodeBanner: false,
hasImportedNostrKey: true,
bitcoinNetwork: "regtest",
useMnemonicForLnurlAuth: true,
Expand Down
5 changes: 0 additions & 5 deletions src/extension/background-script/actions/accounts/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ const edit = async (message: MessageAccountEdit) => {
message.args.isMnemonicBackupDone;
}

if (message.args.seenSharedNodeBanner !== undefined) {
accounts[accountId].seenSharedNodeBanner =
message.args.seenSharedNodeBanner;
}

state.setState({ accounts });
// make sure we immediately persist the updated accounts
await state.getState().saveToStorage();
Expand Down
1 change: 0 additions & 1 deletion src/extension/background-script/actions/accounts/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const get = async (message: MessageAccountGet) => {
// Note: undefined (default for new accounts) it is also considered imported
hasImportedNostrKey: account.hasImportedNostrKey !== false,
bitcoinNetwork: account.bitcoinNetwork || "bitcoin",
seenSharedNodeBanner: account.seenSharedNodeBanner || false,
useMnemonicForLnurlAuth: account.useMnemonicForLnurlAuth || false,
};

Expand Down
2 changes: 0 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export interface Account {
nostrPrivateKey?: string | null;
mnemonic?: string | null;
hasImportedNostrKey?: boolean;
seenSharedNodeBanner?: boolean;
bitcoinNetwork?: BitcoinNetworkType;
isMnemonicBackupDone?: boolean;
useMnemonicForLnurlAuth?: boolean;
Expand Down Expand Up @@ -270,7 +269,6 @@ export interface MessageAccountEdit extends MessageDefault {
bitcoinNetwork?: BitcoinNetworkType;
useMnemonicForLnurlAuth?: boolean;
isMnemonicBackupDone?: boolean;
seenSharedNodeBanner?: boolean;
};
action: "editAccount";
}
Expand Down

0 comments on commit 6f08fe9

Please sign in to comment.