diff --git a/src/components/CreditOfferEditor.jsx b/src/components/CreditOfferEditor.jsx index 65d44b3..aba888e 100644 --- a/src/components/CreditOfferEditor.jsx +++ b/src/components/CreditOfferEditor.jsx @@ -816,6 +816,7 @@ export default function CreditOfferEditor(properties) { otherAsset={null} marketSearch={marketSearch} type={null} + chain={usr.chain} /> ) : null} diff --git a/src/components/Market.jsx b/src/components/Market.jsx index a52016f..7835129 100644 --- a/src/components/Market.jsx +++ b/src/components/Market.jsx @@ -490,6 +490,7 @@ export default function Market(properties) { marketSearch={marketSearch} type={activeLimitCard === "buy" ? "quote" : "base"} size="small" + chain={usr.chain} /> @@ -564,9 +566,11 @@ export default function Market(properties) { - {activeLimitCard === "sell" - ? t("Market:baseAsset") - : t("Market:quoteAsset")} + { + activeLimitCard === "sell" + ? t("Market:baseAsset") + : t("Market:quoteAsset") + } {t("Market:loading")} diff --git a/src/components/Market/AssetDropDownCard.jsx b/src/components/Market/AssetDropDownCard.jsx index 444c072..e067a04 100644 --- a/src/components/Market/AssetDropDownCard.jsx +++ b/src/components/Market/AssetDropDownCard.jsx @@ -1,6 +1,7 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useMemo } from "react"; import Fuse from "fuse.js"; import { FixedSizeList as List } from "react-window"; +import { useStore } from '@nanostores/react'; import { useTranslation } from "react-i18next"; import { i18n as i18nInstance, locale } from "@/lib/i18n.js"; @@ -25,6 +26,12 @@ import { import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; +import { + $favouriteAssets, + addFavouriteAsset, + removeFavouriteAsset, +} from "@/stores/favourites.ts" + /** * Creating an asset dropdown component * @param {String} assetSymbol current asset symbol @@ -74,30 +81,71 @@ export default function AssetDropDown(properties) { }, [thisInput]); const Row = ({ index, style }) => { - const res = thisResult[index]; + const res = mode === "search" + ? thisResult[index] + : relevantAssets[index]; return (
{ setTimeout(() => { - storeCallback(res.item.s); + storeCallback( + mode === "search" + ? res.item.s + : res.symbol, + ); }, 0); setDialogOpen(false); }} > - {res.item.s} ({res.item.id}) + { + mode === "search" + ? `${res.item.s} (${res.item.id})` + : `${res.symbol} (${res.id})` + } - {t("AssetDropDownCard:issued", { user: res.item.u })} + + {t( + "AssetDropDownCard:issued", + { user: mode === "search" ? res.item.u : res.issuer } + )} +
); }; + const [mode, setMode] = useState("search"); + + const favouriteAssets = useStore($favouriteAssets); + + const relevantAssets = useMemo(() => { + if (!chain || !favouriteAssets) { + return []; + } + + const _chainAssets = favouriteAssets[chain]; + + if (!assetSymbol && !otherAsset) { + return _chainAssets; + } + + return _chainAssets.filter( + (asset) => assetSymbol && otherAsset + ? asset.symbol !== assetSymbol && asset.symbol !== otherAsset + : asset.symbol !== assetSymbol + ); + }, [favouriteAssets, assetSymbol, otherAsset, chain]); + return ( @@ -128,25 +175,69 @@ export default function AssetDropDown(properties) { ? t("AssetDropDownCard:replacing", { assetSymbol: assetSymbol }) : t("AssetDropDownCard:selecting")} -

- {!type ? t("AssetDropDownCard:noType") : null} - {type && type === "base" ? t("AssetDropDownCard:baseType") : null} - {type && type === "quote" ? t("AssetDropDownCard:quoteType") : null} -

- { - setThisInput(event.target.value); - }} - /> - {thisResult && thisResult.length ? ( - <> - - {Row} - - - ) : null} + +
+ + +
+ + { + mode === "search" + ? <> +

+ {!type ? t("AssetDropDownCard:noType") : null} + {type && type === "base" ? t("AssetDropDownCard:baseType") : null} + {type && type === "quote" ? t("AssetDropDownCard:quoteType") : null} +

+ { + setThisInput(event.target.value); + }} + /> + {thisResult && thisResult.length ? ( + <> + + {Row} + + + ) : null} + + : null + } + + { + mode === "favourites" + ? <> +

+ {!type ? t("AssetDropDownCard:noType") : null} + {type && type === "base" ? t("AssetDropDownCard:baseType") : null} + {type && type === "quote" ? t("AssetDropDownCard:quoteType") : null} +

+ {relevantAssets && relevantAssets.length ? ( + <> + + {Row} + + + ) : "No favourite assets..."} + + + : null + }
diff --git a/src/components/Market/MarketAssetCard.jsx b/src/components/Market/MarketAssetCard.jsx index 8b71bd0..9f342ea 100644 --- a/src/components/Market/MarketAssetCard.jsx +++ b/src/components/Market/MarketAssetCard.jsx @@ -1,6 +1,11 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useMemo } from "react"; import { useTranslation } from "react-i18next"; import { i18n as i18nInstance, locale } from "@/lib/i18n.js"; +import { + HeartFilledIcon, + HeartIcon +} from "@radix-ui/react-icons" +import { useStore } from '@nanostores/react'; import { Card, @@ -11,6 +16,13 @@ import { CardTitle, } from "@/components/ui/card"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; + import { Dialog, DialogContent, @@ -28,12 +40,23 @@ import ExternalLink from "../common/ExternalLink.jsx"; import CardRow from "../common/CardRow.jsx"; import { humanReadableFloat } from "@/lib/common"; +import { + $favouriteAssets, + addFavouriteAsset, + removeFavouriteAsset, +} from "@/stores/favourites.ts" export default function MarketAssetCard(properties) { const { asset, assetData, assetDetails, bitassetData, marketSearch, chain, usrBalances, type } = properties; const { t, i18n } = useTranslation(locale.get(), { i18n: i18nInstance }); + const favouriteAssets = useStore($favouriteAssets); + + const isFavourite = useMemo(() => { + return favouriteAssets[chain].map(x => x.id).includes(assetData.id); + }, [favouriteAssets, chain, asset]); + const [assetBalance, setAssetBalance] = useState(0); useEffect(() => { if (assetData && usrBalances) { @@ -71,7 +94,43 @@ export default function MarketAssetCard(properties) { - {asset} {assetData ? `(${assetData.id})` : ""} +
+
+ {asset} {assetData ? `(${assetData.id})` : ""} +
+
+ + + + { + isFavourite + ? { + removeFavouriteAsset(chain, { + id: assetData.id, + symbol: assetData.symbol, + issuer: assetData.issuer + }) + }} + /> + : { + addFavouriteAsset(chain, { + id: assetData.id, + symbol: assetData.symbol, + issuer: assetData.issuer + }) + }} + /> + } + + + Favourite + + + +
+
{type === "buy" ? ( diff --git a/src/components/PortfolioTabs.jsx b/src/components/PortfolioTabs.jsx index 94d67c4..133bd87 100644 --- a/src/components/PortfolioTabs.jsx +++ b/src/components/PortfolioTabs.jsx @@ -14,6 +14,7 @@ import { } from "@/components/ui/card"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/ui/hover-card"; import { Dialog, @@ -35,13 +36,9 @@ import { createAccountLimitOrderStore } from "@/nanoeffects/AccountLimitOrders.t import { $currentUser } from "@/stores/users.ts"; import { $currentNode } from "@/stores/node.ts"; +import { $poolCacheBTS, $poolCacheTEST } from "@/stores/cache.ts"; -import { - $assetCacheBTS, - $assetCacheTEST, - $globalParamsCacheBTS, - $globalParamsCacheTEST, -} from "@/stores/cache.ts"; +import { $assetCacheBTS, $assetCacheTEST } from "@/stores/cache.ts"; import DeepLinkDialog from "./common/DeepLinkDialog.jsx"; import ExternalLink from "./common/ExternalLink.jsx"; @@ -49,11 +46,32 @@ import ExternalLink from "./common/ExternalLink.jsx"; import { humanReadableFloat } from "@/lib/common"; import { opTypes } from "@/lib/opTypes"; +function RowHyperlink({ id, share_asset_symbol, asset_a_symbol, asset_b_symbol }) { + return ( +
+
+

{id}

+
+
+

{share_asset_symbol}

+
+
+

{asset_a_symbol}

+
+
+

{asset_b_symbol}

+
+
+ ); +} + export default function PortfolioTabs(properties) { const { t, i18n } = useTranslation(locale.get(), { i18n: i18nInstance }); const usr = useSyncExternalStore($currentUser.subscribe, $currentUser.get, () => true); const currentNode = useStore($currentNode); + const [sortType, setSortType] = useState("default"); + const _assetsBTS = useSyncExternalStore($assetCacheBTS.subscribe, $assetCacheBTS.get, () => true); const _assetsTEST = useSyncExternalStore( $assetCacheTEST.subscribe, @@ -61,6 +79,9 @@ export default function PortfolioTabs(properties) { () => true ); + const _poolsBTS = useSyncExternalStore($poolCacheBTS.subscribe, $poolCacheBTS.get, () => true); + const _poolsTEST = useSyncExternalStore($poolCacheTEST.subscribe, $poolCacheTEST.get, () => true); + const _chain = useMemo(() => { if (usr && usr.chain) { return usr.chain; @@ -68,6 +89,13 @@ export default function PortfolioTabs(properties) { return "bitshares"; }, [usr]); + const pools = useMemo(() => { + if (usr && usr.chain && (_poolsBTS || _poolsTEST)) { + return usr.chain === "bitshares" ? _poolsBTS : _poolsTEST; + } + return []; + }, [_poolsBTS, _poolsTEST, _chain]); + const assets = useMemo(() => { if (_chain && (_assetsBTS || _assetsTEST)) { return _chain === "bitshares" ? _assetsBTS : _assetsTEST; @@ -75,9 +103,7 @@ export default function PortfolioTabs(properties) { return []; }, [_assetsBTS, _assetsTEST, _chain]); - useInitCache(_chain ?? "bitshares", [ - "assets", - ]); + useInitCache(_chain ?? "bitshares", ["assets", "pools"]); const activeTabStyle = { backgroundColor: "#252526", @@ -95,8 +121,39 @@ export default function PortfolioTabs(properties) { unsubscribeUserBalancesStore = userBalancesStore.subscribe(({ data, error, loading }) => { if (data && !error && !loading) { + console.log({data}) + const updatedData = data.map((balance) => { + return { + ...balance, + symbol: assets.find((asset) => asset.id === balance.asset_id).symbol, + } + }); console.log("Successfully fetched balances"); - setBalances(data); + if (sortType === "default") { + setBalances(data); + } else if (sortType === "alphabetical") { + const alphabetical = updatedData.sort((a, b) => { + if (a.symbol < b.symbol) { + return -1; + } + if (a.symbol > b.symbol) { + return 1; + } + return 0; + }); + setBalances(alphabetical); + } else if (sortType === "amount") { + const amount = updatedData.sort((a, b) => { + if (parseInt(a.amount) < parseInt(b.amount)) { + return 1; + } + if (parseInt(a.amount) > parseInt(b.amount)) { + return -1; + } + return 0; + }); + setBalances(amount); + } } }); } @@ -104,7 +161,7 @@ export default function PortfolioTabs(properties) { return () => { if (unsubscribeUserBalancesStore) unsubscribeUserBalancesStore(); } - }, [usr, balanceCounter]); + }, [usr, balanceCounter, sortType, assets]); const [openOrderCounter, setOpenOrderCounter] = useState(0); const [openOrders, setOpenOrders] = useState(); @@ -180,6 +237,9 @@ export default function PortfolioTabs(properties) { const BalanceRow = ({ index, style }) => { const rowBalance = balances[index]; + const _balanceAsset = retrievedBalanceAssets.find((asset) => asset.id === rowBalance.asset_id); + const _balanceAssetSymbol = _balanceAsset.symbol; + const currentBalance = retrievedBalanceAssets && Array.isArray(retrievedBalanceAssets) ? retrievedBalanceAssets.find((asset) => asset.id === rowBalance.asset_id) @@ -195,12 +255,16 @@ export default function PortfolioTabs(properties) { minimumFractionDigits: currentBalance.precision, }); + const relevantPools = pools.filter( + (pool) => pool.asset_a_symbol === currentBalance.symbol || pool.asset_b_symbol === currentBalance.symbol + ); + return (
-
- +
+ {t("PortfolioTabs:assetTitle", { symbol: currentBalance.symbol, @@ -212,7 +276,7 @@ export default function PortfolioTabs(properties) {
-
+
+ + + + + + {t("PoolDialogs:assetAHoverCardContent", { assetA: currentBalance.symbol })} + + + { + const pool = poolArray[index]; + return ( + + + + ); + }; + + return ( + + + + + + + {dialogTitle} + {dialogDescription} + +
+
+
{t("PoolDialogs:idColumnTitle")}
+
{t("PoolDialogs:shareAssetColumnTitle")}
+
{t("PoolDialogs:assetAColumnTitle")}
+
{t("PoolDialogs:assetBColumnTitle")}
+
+ + {PoolRow} + +
+
+
+ ); + }; + return ( <>
@@ -482,11 +609,25 @@ export default function PortfolioTabs(properties) { - + {t("PortfolioTabs:accountBalances", { username: usr.username })} - {t("PortfolioTabs:accountBalancesDescription")} + + {t("PortfolioTabs:accountBalancesDescription")} +
+
+ + + +
+
{balances && @@ -496,7 +637,7 @@ export default function PortfolioTabs(properties) { {BalanceRow} diff --git a/src/components/Smartcoin.jsx b/src/components/Smartcoin.jsx index 91fe6cb..33dfca2 100644 --- a/src/components/Smartcoin.jsx +++ b/src/components/Smartcoin.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect, useSyncExternalStore, useMemo, useCallback import { FixedSizeList as List } from "react-window"; import { useForm } from "react-hook-form"; import { LockOpen2Icon, LockClosedIcon } from "@radix-ui/react-icons"; +import { useStore } from '@nanostores/react'; import { useTranslation } from "react-i18next"; import { i18n as i18nInstance, locale } from "@/lib/i18n.js"; diff --git a/src/components/Smartcoins.jsx b/src/components/Smartcoins.jsx index 406c5a5..0e9bc0d 100644 --- a/src/components/Smartcoins.jsx +++ b/src/components/Smartcoins.jsx @@ -1,6 +1,8 @@ import React, { useState, useEffect, useSyncExternalStore, useMemo, useCallback } from "react"; import { FixedSizeList as List } from "react-window"; import Fuse from "fuse.js"; +import { useStore } from '@nanostores/react'; + import { useTranslation } from "react-i18next"; import { i18n as i18nInstance, locale } from "@/lib/i18n.js"; diff --git a/src/components/Transfer.jsx b/src/components/Transfer.jsx index e292323..1ff81a0 100644 --- a/src/components/Transfer.jsx +++ b/src/components/Transfer.jsx @@ -1,5 +1,6 @@ import React, { useState, useEffect, useSyncExternalStore, useMemo } from "react"; import { useForm } from "react-hook-form"; +import { useStore } from "@nanostores/react"; import { useTranslation } from "react-i18next"; import { i18n as i18nInstance, locale } from "@/lib/i18n.js"; @@ -428,7 +429,7 @@ export default function Transfer(properties) { otherAsset={null} marketSearch={marketSearch} type={null} - /> + chain={usr && usr.chain ? usr.chain : "bitshares"} />
diff --git a/src/data/locales/da/AssetDropDownCard.json b/src/data/locales/da/AssetDropDownCard.json index aafb319..f109d17 100644 --- a/src/data/locales/da/AssetDropDownCard.json +++ b/src/data/locales/da/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "Vælg venligst et nyt basisaktiv", "quoteType": "Vælg venligst et nyt tilbudsaktiv", "search": "Søg efter et aktiv", - "issued": "Udstedt af {{user}}" + "issued": "Udstedt af {{user}}", + "search2": "Søge", + "favourites": "Favoritter" } diff --git a/src/data/locales/da/PortfolioTabs.json b/src/data/locales/da/PortfolioTabs.json index e6341f1..2264aba 100644 --- a/src/data/locales/da/PortfolioTabs.json +++ b/src/data/locales/da/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "Seneste blockchain-aktivitet", "recentBlockchainActivityDescription": "Din seneste blockchain-aktivitet", "noRecentActivityFound": "Der blev ikke fundet nogen nylig aktivitet", - "refreshRecentActivityButton": "Opdater seneste aktivitet" + "refreshRecentActivityButton": "Opdater seneste aktivitet", + "pools": "Pools", + "default": "Misligholdelse", + "alphabetical": "Alfabetisk", + "amount": "Beløb" } diff --git a/src/data/locales/de/AssetDropDownCard.json b/src/data/locales/de/AssetDropDownCard.json index 0a3bc06..6439b1e 100644 --- a/src/data/locales/de/AssetDropDownCard.json +++ b/src/data/locales/de/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "Bitte wählen Sie ein neues Basis-Asset aus", "quoteType": "Bitte wählen Sie ein neues Angebots-Asset aus", "search": "Suchen Sie nach einem Vermögenswert", - "issued": "Ausgestellt von {{user}}" + "issued": "Ausgestellt von {{user}}", + "search2": "Suchen", + "favourites": "Favoriten" } diff --git a/src/data/locales/de/PortfolioTabs.json b/src/data/locales/de/PortfolioTabs.json index 1dd43d5..30b5e1a 100644 --- a/src/data/locales/de/PortfolioTabs.json +++ b/src/data/locales/de/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "Aktuelle Blockchain-Aktivität", "recentBlockchainActivityDescription": "Ihre letzte Blockchain-Aktivität", "noRecentActivityFound": "Keine aktuelle Aktivität gefunden", - "refreshRecentActivityButton": "Aktuelle Aktivität aktualisieren" + "refreshRecentActivityButton": "Aktuelle Aktivität aktualisieren", + "pools": "Pools", + "default": "Standard", + "alphabetical": "Alphabetisch", + "amount": "Menge" } diff --git a/src/data/locales/en/AssetDropDownCard.json b/src/data/locales/en/AssetDropDownCard.json index 8b1a1cf..2c76f0b 100644 --- a/src/data/locales/en/AssetDropDownCard.json +++ b/src/data/locales/en/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "Please select a new base asset", "quoteType": "Please select a new quote asset", "search": "Search for an asset", - "issued": "Issued by {{user}}" + "issued": "Issued by {{user}}", + "search2": "Search", + "favourites": "Favourites" } diff --git a/src/data/locales/en/PortfolioTabs.json b/src/data/locales/en/PortfolioTabs.json index 53bb8e5..73caf8c 100644 --- a/src/data/locales/en/PortfolioTabs.json +++ b/src/data/locales/en/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "Recent blockchain activity", "recentBlockchainActivityDescription": "Your recent blockchain activity", "noRecentActivityFound": "No recent activity found", - "refreshRecentActivityButton": "Refresh recent activity" + "refreshRecentActivityButton": "Refresh recent activity", + "pools": "Pools", + "default": "Default", + "alphabetical": "Alphabetical", + "amount": "Amount" } diff --git a/src/data/locales/es/AssetDropDownCard.json b/src/data/locales/es/AssetDropDownCard.json index 2af6595..7e0c0c8 100644 --- a/src/data/locales/es/AssetDropDownCard.json +++ b/src/data/locales/es/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "Seleccione un nuevo recurso base", "quoteType": "Seleccione un nuevo activo de cotización", "search": "Buscar un activo", - "issued": "Expedido por {{user}}" + "issued": "Expedido por {{user}}", + "search2": "Buscar", + "favourites": "Favoritos" } diff --git a/src/data/locales/es/PortfolioTabs.json b/src/data/locales/es/PortfolioTabs.json index 08cb002..c3c16cd 100644 --- a/src/data/locales/es/PortfolioTabs.json +++ b/src/data/locales/es/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "Actividad reciente de blockchain", "recentBlockchainActivityDescription": "Su actividad reciente en blockchain", "noRecentActivityFound": "No se encontró actividad reciente", - "refreshRecentActivityButton": "Actualizar actividad reciente" + "refreshRecentActivityButton": "Actualizar actividad reciente", + "pools": "Quinielas", + "default": "Por defecto", + "alphabetical": "Alfabético", + "amount": "Cantidad" } diff --git a/src/data/locales/et/AssetDropDownCard.json b/src/data/locales/et/AssetDropDownCard.json index a4e1e95..41e22c0 100644 --- a/src/data/locales/et/AssetDropDownCard.json +++ b/src/data/locales/et/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "Valige uus põhivara", "quoteType": "Valige uus hinnapakkumise vara", "search": "Otsige vara", - "issued": "Välja andnud {{user}}" + "issued": "Välja andnud {{user}}", + "search2": "Otsi", + "favourites": "Lemmikud" } diff --git a/src/data/locales/et/PortfolioTabs.json b/src/data/locales/et/PortfolioTabs.json index 639c97b..c9bd0d3 100644 --- a/src/data/locales/et/PortfolioTabs.json +++ b/src/data/locales/et/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "Hiljutine plokiahela tegevus", "recentBlockchainActivityDescription": "Teie hiljutine tegevus plokiahelas", "noRecentActivityFound": "Hiljutist tegevust ei leitud", - "refreshRecentActivityButton": "Värskendage hiljutisi tegevusi" + "refreshRecentActivityButton": "Värskendage hiljutisi tegevusi", + "pools": "Basseinid", + "default": "Vaikimisi", + "alphabetical": "Tähestikuline", + "amount": "Summa" } diff --git a/src/data/locales/fr/AssetDropDownCard.json b/src/data/locales/fr/AssetDropDownCard.json index c70de1e..f22ecec 100644 --- a/src/data/locales/fr/AssetDropDownCard.json +++ b/src/data/locales/fr/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "Veuillez sélectionner un nouvel actif de base", "quoteType": "Veuillez sélectionner un nouvel actif de devis", "search": "Rechercher un bien", - "issued": "Délivré par {{user}}" + "issued": "Délivré par {{user}}", + "search2": "Recherche", + "favourites": "Favoris" } diff --git a/src/data/locales/fr/PortfolioTabs.json b/src/data/locales/fr/PortfolioTabs.json index 100198e..aa9e856 100644 --- a/src/data/locales/fr/PortfolioTabs.json +++ b/src/data/locales/fr/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "Activité récente de la blockchain", "recentBlockchainActivityDescription": "Votre activité blockchain récente", "noRecentActivityFound": "Aucune activité récente trouvée", - "refreshRecentActivityButton": "Actualiser l'activité récente" + "refreshRecentActivityButton": "Actualiser l'activité récente", + "pools": "Piscines", + "default": "Défaut", + "alphabetical": "Alphabétique", + "amount": "Montant" } diff --git a/src/data/locales/it/AssetDropDownCard.json b/src/data/locales/it/AssetDropDownCard.json index 7a97fa6..d12088c 100644 --- a/src/data/locales/it/AssetDropDownCard.json +++ b/src/data/locales/it/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "Seleziona una nuova risorsa di base", "quoteType": "Seleziona una nuova risorsa preventivo", "search": "Cerca una risorsa", - "issued": "Rilasciato da {{user}}" + "issued": "Rilasciato da {{user}}", + "search2": "Ricerca", + "favourites": "Preferiti" } diff --git a/src/data/locales/it/PortfolioTabs.json b/src/data/locales/it/PortfolioTabs.json index fa4c8fa..60ce01e 100644 --- a/src/data/locales/it/PortfolioTabs.json +++ b/src/data/locales/it/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "Attività recente sulla blockchain", "recentBlockchainActivityDescription": "La tua recente attività blockchain", "noRecentActivityFound": "Nessuna attività recente trovata", - "refreshRecentActivityButton": "Aggiorna l'attività recente" + "refreshRecentActivityButton": "Aggiorna l'attività recente", + "pools": "Piscine", + "default": "Predefinito", + "alphabetical": "Alfabetico", + "amount": "Quantità" } diff --git a/src/data/locales/ja/AssetDropDownCard.json b/src/data/locales/ja/AssetDropDownCard.json index af2602c..bf6a667 100644 --- a/src/data/locales/ja/AssetDropDownCard.json +++ b/src/data/locales/ja/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "新しいベースアセットを選択してください", "quoteType": "新しい見積資産を選択してください", "search": "アセットを検索する", - "issued": "発行者 {{user}}" + "issued": "発行者 {{user}}", + "search2": "検索", + "favourites": "お気に入り" } diff --git a/src/data/locales/ja/PortfolioTabs.json b/src/data/locales/ja/PortfolioTabs.json index da037fe..c6e0c2f 100644 --- a/src/data/locales/ja/PortfolioTabs.json +++ b/src/data/locales/ja/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "最近のブロックチェーン活動", "recentBlockchainActivityDescription": "最近のブロックチェーン アクティビティ", "noRecentActivityFound": "最近のアクティビティは見つかりませんでした", - "refreshRecentActivityButton": "最近のアクティビティを更新する" + "refreshRecentActivityButton": "最近のアクティビティを更新する", + "pools": "プール", + "default": "デフォルト", + "alphabetical": "アルファベット順", + "amount": "額" } diff --git a/src/data/locales/ko/AssetDropDownCard.json b/src/data/locales/ko/AssetDropDownCard.json index 2261d92..420a465 100644 --- a/src/data/locales/ko/AssetDropDownCard.json +++ b/src/data/locales/ko/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "새 기본 자산을 선택하세요.", "quoteType": "새 견적 자산을 선택하세요.", "search": "자산 검색", - "issued": "발행자 {{user}}" + "issued": "발행자 {{user}}", + "search2": "찾다", + "favourites": "즐겨찾기" } diff --git a/src/data/locales/ko/PortfolioTabs.json b/src/data/locales/ko/PortfolioTabs.json index f4962bc..86d4ece 100644 --- a/src/data/locales/ko/PortfolioTabs.json +++ b/src/data/locales/ko/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "최근 블록체인 활동", "recentBlockchainActivityDescription": "최근 블록체인 활동", "noRecentActivityFound": "최근 활동이 없습니다.", - "refreshRecentActivityButton": "최근 활동 새로 고침" + "refreshRecentActivityButton": "최근 활동 새로 고침", + "pools": "풀", + "default": "기본", + "alphabetical": "알파벳순", + "amount": "양" } diff --git a/src/data/locales/pt/AssetDropDownCard.json b/src/data/locales/pt/AssetDropDownCard.json index a5260e8..f262ed9 100644 --- a/src/data/locales/pt/AssetDropDownCard.json +++ b/src/data/locales/pt/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "Selecione um novo recurso base", "quoteType": "Selecione um novo ativo de cotação", "search": "Procure um ativo", - "issued": "Emitida pela {{user}}" + "issued": "Emitida pela {{user}}", + "search2": "찾다", + "favourites": "즐겨찾기" } diff --git a/src/data/locales/pt/PortfolioTabs.json b/src/data/locales/pt/PortfolioTabs.json index 1b026f1..493f9f3 100644 --- a/src/data/locales/pt/PortfolioTabs.json +++ b/src/data/locales/pt/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "Atividade recente de blockchain", "recentBlockchainActivityDescription": "Sua atividade recente de blockchain", "noRecentActivityFound": "Nenhuma atividade recente encontrada", - "refreshRecentActivityButton": "Atualizar atividade recente" + "refreshRecentActivityButton": "Atualizar atividade recente", + "pools": "Piscinas", + "default": "Padrão", + "alphabetical": "Alfabético", + "amount": "Quantia" } diff --git a/src/data/locales/th/AssetDropDownCard.json b/src/data/locales/th/AssetDropDownCard.json index 538c0ad..b2879dc 100644 --- a/src/data/locales/th/AssetDropDownCard.json +++ b/src/data/locales/th/AssetDropDownCard.json @@ -7,5 +7,7 @@ "baseType": "โปรดเลือกสินทรัพย์ฐานใหม่", "quoteType": "โปรดเลือกสินทรัพย์ใบเสนอราคาใหม่", "search": "ค้นหาสินทรัพย์", - "issued": "ออกโดย {{user}}" + "issued": "ออกโดย {{user}}", + "search2": "ค้นหา", + "favourites": "รายการโปรด" } diff --git a/src/data/locales/th/PortfolioTabs.json b/src/data/locales/th/PortfolioTabs.json index 11c2270..8822e61 100644 --- a/src/data/locales/th/PortfolioTabs.json +++ b/src/data/locales/th/PortfolioTabs.json @@ -43,5 +43,9 @@ "recentBlockchainActivityTitle": "กิจกรรมบล็อกเชนล่าสุด", "recentBlockchainActivityDescription": "กิจกรรมบล็อกเชนล่าสุดของคุณ", "noRecentActivityFound": "ไม่พบกิจกรรมล่าสุด", - "refreshRecentActivityButton": "รีเฟรชกิจกรรมล่าสุด" + "refreshRecentActivityButton": "รีเฟรชกิจกรรมล่าสุด", + "pools": "สระน้ำ", + "default": "ค่าเริ่มต้น", + "alphabetical": "ตามตัวอักษร", + "amount": "จำนวน" } diff --git a/src/stores/favourites.ts b/src/stores/favourites.ts new file mode 100644 index 0000000..d947b68 --- /dev/null +++ b/src/stores/favourites.ts @@ -0,0 +1,111 @@ +import { persistentMap } from "@nanostores/persistent"; + +type Asset = { + symbol: string; + id: string; + issuer: string; +} + +type User = { + name: string; + id: string; +} + +type StoredAssets = { + bitshares: Asset[] | []; + bitshares_testnet: Asset[] | []; +} + +type StoredUsers = { + bitshares: User[] | []; + bitshares_testnet: User[] | []; +} + +const $favouriteAssets = persistentMap( + "favouriteAssets", + { + bitshares: [], + bitshares_testnet: [] + }, + { + encode(value) { + return JSON.stringify(value); + }, + decode(value) { + try { + return JSON.parse(value); + } catch (e) { + console.log(e); + return value; + } + } + } +); + +const $favouriteUsers = persistentMap( + "favouriteUsers", + { + bitshares: [], + bitshares_testnet: [] + }, + { + encode(value) { + return JSON.stringify(value); + }, + decode(value) { + try { + return JSON.parse(value); + } catch (e) { + console.log(e); + return value; + } + } + } +); + +function addFavouriteAsset(chain: string, asset: Asset) { + const assets = $favouriteAssets.get()[chain]; + if (assets.find((a) => a.id === asset.id)) { + return; // already exists + } + assets.push(asset); + $favouriteAssets.set({ ...$favouriteAssets.get(), [chain]: assets }); +} + +function removeFavouriteAsset(chain: string, asset: Asset) { + const assets = $favouriteAssets.get()[chain]; + const index = assets.findIndex((a) => a.id === asset.id); + if (index === -1) { + return; // not found + } + assets.splice(index, 1); + $favouriteAssets.set({ ...$favouriteAssets.get(), [chain]: assets }); +} + +function addFavouriteUser(chain: string, user: User) { + const users = $favouriteUsers.get()[chain]; + if (users.find((u) => u.id === user.id)) { + return; // already exists + } + users.push(user); + $favouriteUsers.set({ ...$favouriteUsers.get(), [chain]: users }); +} + +function removeFavouriteUser(chain: string, user: User) { + const users = $favouriteUsers.get()[chain]; + const index = users.findIndex((u) => u.id === user.id); + if (index === -1) { + return; // not found + } + users.splice(index, 1); + $favouriteUsers.set({ ...$favouriteUsers.get(), [chain]: users }); +} + +export { + $favouriteAssets, + $favouriteUsers, + addFavouriteAsset, + addFavouriteUser, + removeFavouriteAsset, + removeFavouriteUser +}; \ No newline at end of file diff --git a/src/stores/node.ts b/src/stores/node.ts index 8510be6..c3b96ea 100644 --- a/src/stores/node.ts +++ b/src/stores/node.ts @@ -10,8 +10,8 @@ type Node = { const $currentNode = map({ url: "", chain: "" }); function setCurrentNode(chain: string, url?: string) { - if (!(chains as any)[chain] || url && !(chains as any)[chain].nodeList.find((node: any) => node.url === url)) { - return; // block invalid nodes + if (!(chains as any)[chain]) { + return; } $currentNode.set({ chain, url: url ?? (chains as any)[chain].nodeList[0].url });