fix: redirect transfer transactions to user profile
This commit is contained in:
parent
8b5f341819
commit
a47f9654a6
2 changed files with 17 additions and 9 deletions
|
|
@ -93,10 +93,14 @@
|
|||
setOpenMobile(false);
|
||||
}
|
||||
|
||||
async function handleTradeClick(coinSymbol: string) {
|
||||
const targetPath = `/coin/${coinSymbol.toLowerCase()}`;
|
||||
|
||||
await goto(targetPath, { invalidateAll: true });
|
||||
async function handleTradeClick(coinSymbol: string, trade: any) {
|
||||
if (trade.type === 'TRANSFER_IN' || trade.type === 'TRANSFER_OUT') {
|
||||
const targetPath = `/user/${trade.username}`;
|
||||
await goto(targetPath, { invalidateAll: true });
|
||||
} else {
|
||||
const targetPath = `/coin/${coinSymbol.toLowerCase()}`;
|
||||
await goto(targetPath, { invalidateAll: true });
|
||||
}
|
||||
setOpenMobile(false);
|
||||
}
|
||||
|
||||
|
|
@ -252,7 +256,7 @@
|
|||
{:else}
|
||||
{#each $liveTradesStore.slice(0, 5) as trade, index (`${trade.timestamp}-${trade.username}-${trade.coinSymbol}-${index}`)}
|
||||
<button
|
||||
onclick={() => handleTradeClick(trade.coinSymbol)}
|
||||
onclick={() => handleTradeClick(trade.coinSymbol, trade)}
|
||||
class="hover:bg-muted/50 flex w-full cursor-pointer items-center gap-2 rounded px-1 py-1 text-left text-xs transition-colors"
|
||||
>
|
||||
<div class="flex items-center gap-1">
|
||||
|
|
|
|||
|
|
@ -17,8 +17,12 @@
|
|||
goto(`/user/${username}`);
|
||||
}
|
||||
|
||||
function handleCoinClick(coinSymbol: string) {
|
||||
goto(`/coin/${coinSymbol.toLowerCase()}`);
|
||||
function handleCoinClick(coinSymbol: string, trade: any) {
|
||||
if (trade.type === 'TRANSFER_IN' || trade.type === 'TRANSFER_OUT') {
|
||||
goto(`/user/${trade.username}`);
|
||||
} else {
|
||||
goto(`/coin/${coinSymbol.toLowerCase()}`);
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
|
|
@ -84,7 +88,7 @@
|
|||
{#if trade.type === 'TRANSFER_IN' || trade.type === 'TRANSFER_OUT'}
|
||||
{#if trade.amount > 0}
|
||||
<button
|
||||
onclick={() => handleCoinClick(trade.coinSymbol)}
|
||||
onclick={() => handleCoinClick(trade.coinSymbol, trade)}
|
||||
class="flex cursor-pointer items-center gap-1.5 transition-opacity hover:underline hover:opacity-80"
|
||||
>
|
||||
<CoinIcon
|
||||
|
|
@ -111,7 +115,7 @@
|
|||
{/if}
|
||||
{:else}
|
||||
<button
|
||||
onclick={() => handleCoinClick(trade.coinSymbol)}
|
||||
onclick={() => handleCoinClick(trade.coinSymbol, trade)}
|
||||
class="flex cursor-pointer items-center gap-1.5 transition-opacity hover:underline hover:opacity-80"
|
||||
>
|
||||
<CoinIcon
|
||||
|
|
|
|||
Reference in a new issue