Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Fixes #44

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/service/wallet/storeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TonConnectError } from '../../entries/exception';
import { Network } from '../../entries/network';
import { CONNECT_EVENT_ERROR_CODES } from '../../entries/tonConnect';
import { WalletState } from '../../entries/wallet';
import { emojis } from "../../utils/emojis";
import { emojis } from '../../utils/emojis';

export const getWalletState = async (storage: IStorage, publicKey: string) => {
const state = await storage.get<WalletState>(`${AppKey.WALLET}_${publicKey}`);
Expand Down
22 changes: 12 additions & 10 deletions packages/core/src/service/walletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,18 @@ export const updateWalletVersion = async (
export const updateWalletProperty = async (
storage: IStorage,
wallet: WalletState,
props: Pick<
WalletState,
| 'name'
| 'hiddenJettons'
| 'shownJettons'
| 'orderJettons'
| 'lang'
| 'fiat'
| 'network'
| 'emoji'
props: Partial<
Pick<
WalletState,
| 'name'
| 'hiddenJettons'
| 'shownJettons'
| 'orderJettons'
| 'lang'
| 'fiat'
| 'network'
| 'emoji'
>
>
) => {
const updated: WalletState = {
Expand Down
6 changes: 5 additions & 1 deletion packages/uikit/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ export const Header: FC<{ showQrScan?: boolean }> = ({ showQrScan = true }) => {
const { t } = useTranslation();
const wallet = useWalletContext();
const [isOpen, setOpen] = useState(false);

const { account } = useAppContext();
const shouldShowIcon = account.publicKeys.length > 1;

return (
<Block center>
<DropDown
Expand All @@ -215,7 +219,7 @@ export const Header: FC<{ showQrScan?: boolean }> = ({ showQrScan = true }) => {
)}
>
<Title>
<WalletEmoji emoji={wallet.emoji} />
{shouldShowIcon && <WalletEmoji emoji={wallet.emoji} />}
<TitleName> {wallet.name ? wallet.name : t('wallet_title')}</TitleName>

<DownIconWrapper>
Expand Down
7 changes: 6 additions & 1 deletion packages/uikit/src/components/aside/AsideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export const AsideMenuAccount: FC<{ publicKey: string; isSelected: boolean }> =
const { mutate } = useMutateActiveWallet();
const navigate = useNavigate();

const { account } = useAppContext();
const shouldShowIcon = account.publicKeys.length > 1;

const handleNavigateHome = useCallback(() => {
if (location.pathname !== AppRoute.home) {
return navigate(AppRoute.home);
Expand All @@ -103,7 +106,9 @@ export const AsideMenuAccount: FC<{ publicKey: string; isSelected: boolean }> =

return (
<AsideMenuCard isSelected={isSelected} onClick={onClick}>
<WalletEmoji emojiSize="16px" containerSize="16px" emoji={wallet.emoji} />
{shouldShowIcon && (
<WalletEmoji emojiSize="16px" containerSize="16px" emoji={wallet.emoji} />
)}
<Body2>{name}</Body2>
</AsideMenuCard>
);
Expand Down
9 changes: 7 additions & 2 deletions packages/uikit/src/state/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ export const useMutateRenameWallet = (wallet: WalletState) => {
throw new Error('Missing name');
}

await updateWalletProperty(sdk.storage, wallet, form);
const formToUpdate = {
...(form.emoji && { emoji: form.emoji }),
...(form.name && { name: form.name })
};

await updateWalletProperty(sdk.storage, wallet, formToUpdate);
await client.invalidateQueries([QueryKey.account]);
});
};
Expand All @@ -84,7 +89,7 @@ export const useMutateWalletProperty = (clearWallet = false) => {
Partial<
Pick<
WalletState,
'name' | 'hiddenJettons' | 'orderJettons' | 'lang' | 'fiat' | 'network'
'name' | 'hiddenJettons' | 'orderJettons' | 'lang' | 'fiat' | 'network' | 'emoji'
>
>
>(async props => {
Expand Down
Loading