Skip to content

Commit

Permalink
feat: show only single info banner
Browse files Browse the repository at this point in the history
remove update wallet banner
  • Loading branch information
pavanjoshi914 committed Jan 17, 2025
1 parent 039aabe commit ac27669
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 81 deletions.
2 changes: 1 addition & 1 deletion src/app/components/Alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Props = {
type: "warn" | "info";
children: React.ReactNode;
showClose?: boolean;
onClose?: () => void; // Optional callback function
onClose?: () => void;
};

export default function Alert({
Expand Down
73 changes: 8 additions & 65 deletions src/app/screens/Home/DefaultView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ 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>(true);
const [hasSeenInfoBanner, setHasSeenInfoBanner] = useState<boolean>(true);

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

setSeenSharedNodeBanner(userAccount.seenSharedNodeBanner);
setHasSeenInfoBanner(userAccount.hasSeenInfoBanner);

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

{account?.sharedNode && !seenSharedNodeBanner && (
{(account?.usingFeeCredits || account?.nodeRequired) &&
!hasSeenInfoBanner ? (
<Alert
type="info"
showClose
onClose={async () =>
await api.editAccount(account.id, {
seenSharedNodeBanner: true,
hasSeenInfoBanner: true,
})
}
>
Expand All @@ -196,33 +196,8 @@ const DefaultView: FC<Props> = (props) => {
</div>
<span className="text-sm">
<Trans
i18nKey={"default_view.using_shared_node"}
t={t}
components={[
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://getalby.com/node/embrace_albyhub"
target="_blank"
rel="noopener nofollow"
/>,
]}
/>
</span>
</div>
</Alert>
)}

{account?.usingFeeCredits && (
<Alert type="info">
<div className="flex items-center gap-2">
<div className="shrink-0">
<PopiconsCircleExclamationLine className="w-5 h-5" />
</div>
<span className="text-sm">
<Trans
i18nKey={"default_view.using_fee_credits"}
t={t}
i18nKey={"setup_wallet"}
t={tCommon}
values={{
max_account_balance: getFormattedSats(
account?.limits?.max_account_balance || 0
Expand All @@ -232,39 +207,7 @@ const DefaultView: FC<Props> = (props) => {
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://getalby.com/onboarding/node/new"
target="_blank"
rel="noopener nofollow"
/>,
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://guides.getalby.com/user-guide/alby-account-and-browser-extension/alby-account/faqs-alby-account/what-are-fee-credits-in-my-alby-account"
target="_blank"
rel="noopener nofollow"
/>,
]}
/>
</span>
</div>
</Alert>
)}

{account?.nodeRequired ? (
<Alert type="info">
<div className="flex items-center gap-2">
<div className="shrink-0">
<PopiconsCircleExclamationLine className="w-5 h-5" />
</div>
<span className="text-sm">
<Trans
i18nKey={"node_required"}
t={tCommon}
components={[
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://getalby.com/onboarding/node/new"
href="https://getalby.com/node/embrace_albyhub"
target="_blank"
rel="noopener nofollow"
/>,
Expand Down
11 changes: 9 additions & 2 deletions src/app/screens/Options/TestConnection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useSettings } from "~/app/context/SettingsContext";
import TestConnectionResultCard from "~/app/screens/Options/TestConnection/card";
import api from "~/common/lib/api";
import msg from "~/common/lib/msg";

import type { AccountInfo } from "~/types";

export default function TestConnection() {
Expand All @@ -30,6 +31,7 @@ export default function TestConnection() {
}>();
const [errorMessage, setErrorMessage] = useState("");
const [loading, setLoading] = useState(false);
const { getFormattedSats } = useSettings();

const navigate = useNavigate();
const { t } = useTranslation("translation", {
Expand Down Expand Up @@ -127,13 +129,18 @@ export default function TestConnection() {
</div>
<span className="text-sm">
<Trans
i18nKey={"node_required"}
i18nKey={"setup_wallet"}
t={tCommon}
values={{
max_account_balance: getFormattedSats(
account?.limits?.max_account_balance || 0
),
}}
components={[
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://getalby.com/onboarding/node/new"
href="https://getalby.com/node/embrace_albyhub"
target="_blank"
rel="noopener nofollow"
/>,
Expand Down
2 changes: 1 addition & 1 deletion src/common/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export interface GetAccountRes extends Pick<Account, "id" | "name"> {
hasMnemonic: boolean;
isMnemonicBackupDone: boolean;
hasImportedNostrKey: boolean;
seenSharedNodeBanner: boolean;
hasSeenInfoBanner: boolean;
bitcoinNetwork: BitcoinNetworkType;
useMnemonicForLnurlAuth: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("account info", () => {
nostrEnabled: false,
liquidEnabled: false,
hasMnemonic: false,
seenSharedNodeBanner: false,
hasSeenInfoBanner: false,
hasImportedNostrKey: true,
bitcoinNetwork: "bitcoin",
useMnemonicForLnurlAuth: false,
Expand Down Expand Up @@ -92,7 +92,7 @@ describe("account info", () => {
nostrEnabled: true,
liquidEnabled: true,
hasMnemonic: true,
seenSharedNodeBanner: false,
hasSeenInfoBanner: false,
hasImportedNostrKey: true,
bitcoinNetwork: "regtest",
useMnemonicForLnurlAuth: true,
Expand Down
5 changes: 2 additions & 3 deletions src/extension/background-script/actions/accounts/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ const edit = async (message: MessageAccountEdit) => {
message.args.isMnemonicBackupDone;
}

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

state.setState({ accounts });
Expand Down
2 changes: 1 addition & 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,7 @@ 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,
hasSeenInfoBanner: account.hasSeenInfoBanner || false,
useMnemonicForLnurlAuth: account.useMnemonicForLnurlAuth || false,
};

Expand Down
6 changes: 2 additions & 4 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,7 @@
"description": "Fund your account and receive via your lightning address or an invoice"
}
},
"upgrade_account": "You are using the old LNDHub setup. <0>Please re-connect</0> your Alby account to get access to the latest features.",
"using_fee_credits": "Finish your setup and connect your wallet to your <0>Alby account</0> for unlimited payments. Until your setup is complete, you can receive up to {{max_account_balance}} sats as <1>fee credits</1>",
"using_shared_node": "The shared wallet that you use is being deprecated in favor of the Alby Hub wallet. To continue sending and receiving payments <0>setup your wallet</0> by January 3, 2025."
"upgrade_account": "You are using the old LNDHub setup. <0>Please re-connect</0> your Alby account to get access to the latest features."
}
},
"accounts": {
Expand Down Expand Up @@ -1142,7 +1140,7 @@
"website": "Website",
"wallet_settings": "Wallet Settings",
"apps": "Apps",
"node_required": "Finish setting up your wallet to start sending and receiving unlimited payments <0>here</0>. Until then, you can receive up to 50,000 sats as <1>fee credits</1> only.",
"setup_wallet": "<0>Finish your setup</0> and connect your wallet to your Alby account for unlimited payments. Until your setup is complete, you can receive up to {{max_account_balance}} as <1>fee credits</1>",
"actions": {
"back": "Back",
"delete": "Delete",
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface Account {
nostrPrivateKey?: string | null;
mnemonic?: string | null;
hasImportedNostrKey?: boolean;
seenSharedNodeBanner?: boolean;
hasSeenInfoBanner?: boolean;
bitcoinNetwork?: BitcoinNetworkType;
isMnemonicBackupDone?: boolean;
useMnemonicForLnurlAuth?: boolean;
Expand Down Expand Up @@ -270,7 +270,7 @@ export interface MessageAccountEdit extends MessageDefault {
bitcoinNetwork?: BitcoinNetworkType;
useMnemonicForLnurlAuth?: boolean;
isMnemonicBackupDone?: boolean;
seenSharedNodeBanner?: boolean;
hasSeenInfoBanner?: boolean;
};
action: "editAccount";
}
Expand Down

0 comments on commit ac27669

Please sign in to comment.