Skip to content

Commit

Permalink
fix: Resolve F2Pool navigation issue on mobile (#6453)
Browse files Browse the repository at this point in the history
  • Loading branch information
originalix authored Jan 7, 2025
1 parent ce83763 commit 83441f4
Show file tree
Hide file tree
Showing 23 changed files with 182 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function SpeedUpAction({ networkId, onSpeedUp }: ISpeedUpActionProps) {
if (useActionList) {
return (
<ActionList
title="Speed up"
title={intl.formatMessage({ id: ETranslations.global_speed_up })}
sections={sections}
renderTrigger={
<Button size="small" variant="primary">
Expand Down
19 changes: 14 additions & 5 deletions packages/kit/src/hooks/useReplaceTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback } from 'react';

import { useIntl } from 'react-intl';

import { Toast } from '@onekeyhq/components';
import { Toast, useMedia } from '@onekeyhq/components';
import { useBrowserAction } from '@onekeyhq/kit/src/states/jotai/contexts/discovery';
import { ETranslations } from '@onekeyhq/shared/src/locale';
import { EModalRoutes, EModalSendRoutes } from '@onekeyhq/shared/src/routes';
Expand All @@ -29,6 +29,7 @@ function useReplaceTx({
}) {
const navigation = useAppNavigation();
const intl = useIntl();
const { gtMd } = useMedia();
const { handleOpenWebSite } = useBrowserAction().current;

const canReplaceTx = usePromiseResult(async () => {
Expand Down Expand Up @@ -135,7 +136,7 @@ function useReplaceTx({
onConfirm: async () => {
// https://www.f2pool.com/user/tx-acc?from=onekey&txid={txid}
handleOpenWebSite({
switchToMultiTabBrowser: true,
switchToMultiTabBrowser: gtMd,
navigation,
useCurrentWindow: false,
webSite: {
Expand All @@ -159,7 +160,15 @@ function useReplaceTx({
});
}
},
[canReplaceTx, historyTx, intl, navigation, onSuccess, handleOpenWebSite],
[
canReplaceTx,
historyTx,
intl,
navigation,
onSuccess,
handleOpenWebSite,
gtMd,
],
);

const handleCheckSpeedUpState = useCallback(async () => {
Expand All @@ -171,15 +180,15 @@ function useReplaceTx({
}
// https://www.f2pool.com/user/tx-acc?from=onekey&txid={txid}
handleOpenWebSite({
switchToMultiTabBrowser: true,
switchToMultiTabBrowser: gtMd,
navigation,
useCurrentWindow: false,
webSite: {
url: `https://www.f2pool.com/user/tx-acc?query=${txid}`,
title: 'F2Pool',
},
});
}, [historyTx, cancelTxConfig, handleOpenWebSite, navigation]);
}, [historyTx, cancelTxConfig, handleOpenWebSite, navigation, gtMd]);

return {
canReplaceTx,
Expand Down
48 changes: 27 additions & 21 deletions packages/kit/src/states/jotai/contexts/discovery/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,28 +674,34 @@ class ContextJotaiActionsDiscovery extends ContextJotaiActionsBase {
if (webSite?.url) {
webSite.url = processWebSiteUrl(webSite.url) ?? webSite.url;
}
const isNewWindow = !useCurrentWindow;

if (!useCurrentWindow) {
const disabledAddedNewTab = get(disabledAddedNewTabAtom());
if (disabledAddedNewTab) {
Toast.message({
title: appLocale.intl.formatMessage(
{ id: ETranslations.explore_toast_tab_limit_reached },
{ number: '20' },
),
});
return;
}
let delayTime = 0;
if (shouldPopNavigation) {
delayTime = 300;
}
this.setDisplayHomePage.call(set, false);
void this.openMatchDApp.call(set, {
webSite,
dApp,
isNewWindow,
tabId,
});
if (platformEnv.isDesktop || switchToMultiTabBrowser) {
setTimeout(() => {
const isNewWindow = !useCurrentWindow;

if (!useCurrentWindow) {
const disabledAddedNewTab = get(disabledAddedNewTabAtom());
if (disabledAddedNewTab) {
Toast.message({
title: appLocale.intl.formatMessage(
{ id: ETranslations.explore_toast_tab_limit_reached },
{ number: '20' },
),
});
return;
}
}
this.setDisplayHomePage.call(set, false);
void this.openMatchDApp.call(set, {
webSite,
dApp,
isNewWindow,
tabId,
});
}, delayTime);
if (switchToMultiTabBrowser || platformEnv.isDesktop) {
navigation.switchTab(ETabRoutes.MultiTabBrowser);
} else if (shouldPopNavigation) {
navigation.switchTab(ETabRoutes.Discovery);
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/src/locale/json/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
"auth.new_password_form_label": "নতুন পাসওয়ার্ড",
"auth.new_password_form_placeholder": "একটি শক্তিশালী পাসওয়ার্ড তৈরি করুন",
"auth.new_password_same_as_old": "নতুন পাসওয়ার্ডটি পুরানো পাসওয়ার্ড থেকে ভিন্ন হতে হবে",
"auth.passcode_cooldown": "আবার চেষ্টা করুন {cooldowntime} পরে",
"auth.passcode_cooldown": "{cooldowntime} মিনিট পর আবার চেষ্টা করুন",
"auth.passcode_failed_alert": "{count} বার ব্যর্থ প্রচেষ্টা ডিভাইসটি রিসেট করবে",
"auth.passcode_set": "পাসওয়ার্ড কোড সেট",
"auth.passcode_set": "পাসকোড সেট",
"auth.password_set": "পাসওয়ার্ড সেট করা হয়েছে",
"auth.set_passcode": "পাসকোড সেট করুন",
"auth.set_password": "পাসওয়ার্ড সেট করুন",
Expand Down Expand Up @@ -1717,7 +1717,7 @@
"settings.connected_sites": "সংযুক্ত সাইটগুলি",
"settings.create_remove_wallets": "পাসওয়ার্ড ছাড়া ওয়ালেট তৈরি / অপসারণ করুন",
"settings.create_remove_wallets_desc": "ওয়ালেট তৈরি / অপসারণ করার জন্য কোনও পাসওয়ার্ডের প্রয়োজন নেই",
"settings.create_transactions": "পাসওয়ার্ড ছাড়া লেনদেন তৈরি করুন",
"settings.create_transactions": "পাসউকোড ছাড়াই লেনদেন তৈরি করুন",
"settings.create_transactions_desc": "লেনদেনের জন্য কোনও পাসওয়ার্ড প্রয়োজন নেই",
"settings.cryptocurrency": "ক্রিপ্টোকারেন্সি",
"settings.default_currency": "ডিফল্ট মুদ্রা",
Expand Down
12 changes: 6 additions & 6 deletions packages/shared/src/locale/json/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
"auth.new_password_form_label": "Neues Passwort",
"auth.new_password_form_placeholder": "Erstellen Sie ein starkes Passwort",
"auth.new_password_same_as_old": "Das neue Passwort muss sich vom alten unterscheiden",
"auth.passcode_cooldown": "Versuchen Sie es in {cooldowntime} erneut",
"auth.passcode_cooldown": "Versuchen Sie es in {cooldowntime} Minuten erneut",
"auth.passcode_failed_alert": "{count} weitere fehlgeschlagene Versuche werden das Gerät zurücksetzen",
"auth.passcode_set": "Passwcode gesetzt",
"auth.passcode_set": "Passcode festgelegt",
"auth.password_set": "Passwort festgelegt",
"auth.set_passcode": "Passcode festlegen",
"auth.set_password": "Passwort festlegen",
Expand Down Expand Up @@ -1715,10 +1715,10 @@
"settings.clear_pending_transactions_desc": "Löschen Sie die ausstehenden Daten im lokalen Verlaufsdatensatz.",
"settings.clear_successful": "Erfolgreich gelöscht",
"settings.connected_sites": "Verbundene Seiten",
"settings.create_remove_wallets": "Erstellen / Entfernen von Wallets ohne Passwort",
"settings.create_remove_wallets_desc": "Kein Passwort erforderlich für das Erstellen/Entfernen von Geldbörsen",
"settings.create_transactions": "Transaktion ohne Passwort erstellen",
"settings.create_transactions_desc": "Kein Passwort für Transaktionen erforderlich",
"settings.create_remove_wallets": "Wallets ohne Passcode erstellen/entfernen",
"settings.create_remove_wallets_desc": "Zum Erstellen/Entfernen von Wallets ist kein Passcode erforderlich",
"settings.create_transactions": "Transaktion ohne Passcode erstellen",
"settings.create_transactions_desc": "Für Transaktionen ist kein Passcode erforderlich",
"settings.cryptocurrency": "Kryptowährung",
"settings.default_currency": "Standardwährung",
"settings.default_wallet_settings": "Standard Wallet-Einstellungen",
Expand Down
12 changes: 6 additions & 6 deletions packages/shared/src/locale/json/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"auth.new_password_form_label": "New password",
"auth.new_password_form_placeholder": "Create a strong password",
"auth.new_password_same_as_old": "New password must differ from the old one",
"auth.passcode_cooldown": "Try again in {cooldowntime}",
"auth.passcode_cooldown": "Try again in {cooldowntime} minutes",
"auth.passcode_failed_alert": "{count} more failed attempts will reset the device",
"auth.passcode_set": "Passcode set",
"auth.password_set": "Password set",
Expand Down Expand Up @@ -1715,10 +1715,10 @@
"settings.clear_pending_transactions_desc": "Clear the pending data in the local history record.",
"settings.clear_successful": "Clear successful",
"settings.connected_sites": "Connected sites",
"settings.create_remove_wallets": "Create / remove wallets without password",
"settings.create_remove_wallets_desc": "No password needed for creating/removing wallets",
"settings.create_transactions": "Create transaction without password",
"settings.create_transactions_desc": "No password needed for transactions",
"settings.create_remove_wallets": "Create / remove wallets without passcode",
"settings.create_remove_wallets_desc": "No passcode needed for creating/removing wallets",
"settings.create_transactions": "Create transaction without passwcode",
"settings.create_transactions_desc": "No passcode needed for transactions",
"settings.cryptocurrency": "Cryptocurrency",
"settings.default_currency": "Default currency",
"settings.default_wallet_settings": "Default wallet settings",
Expand Down Expand Up @@ -1757,7 +1757,7 @@
"settings.onekey_lite_desc": "Restore your wallet without typing one word.",
"settings.onekey_wants_to_use_nfc": "\"OneKey\" wants to use NFC",
"settings.onekey_wants_to_use_nfc_desc": "To connect to OneKey Lite, NFC permissions are required.",
"settings.passcode_bypass": "passcode bypass",
"settings.passcode_bypass": "Passcode bypass",
"settings.passcode_bypass_desc": "When the allowed time of 2 hours is exceeded, passcode verification is still required to ensure security.",
"settings.passkey": "PassKey",
"settings.password_bypass": "Password bypass",
Expand Down
14 changes: 7 additions & 7 deletions packages/shared/src/locale/json/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
"auth.new_password_form_label": "New password",
"auth.new_password_form_placeholder": "Create a strong password",
"auth.new_password_same_as_old": "New password must differ from the old one",
"auth.passcode_cooldown": "Try again in {cooldowntime}",
"auth.passcode_cooldown": "Try again in {cooldowntime} min",
"auth.passcode_failed_alert": "{count} more failed attempts will reset the device",
"auth.passcode_set": "Passwcode set",
"auth.passcode_set": "Passcode set",
"auth.password_set": "Password set",
"auth.set_passcode": "Set passcode",
"auth.set_password": "Set password",
Expand Down Expand Up @@ -1715,10 +1715,10 @@
"settings.clear_pending_transactions_desc": "Clear the pending data in the local history record.",
"settings.clear_successful": "Clear successful",
"settings.connected_sites": "Connected sites",
"settings.create_remove_wallets": "Create / remove wallets without password",
"settings.create_remove_wallets_desc": "No password needed for creating/removing wallets",
"settings.create_transactions": "Create transaction without password",
"settings.create_transactions_desc": "No password needed for transactions",
"settings.create_remove_wallets": "Create / remove wallets without passcode",
"settings.create_remove_wallets_desc": "No passcode needed for creating/removing wallets",
"settings.create_transactions": "Create transaction without passwcode",
"settings.create_transactions_desc": "No passcode needed for transactions",
"settings.cryptocurrency": "Cryptocurrency",
"settings.default_currency": "Default currency",
"settings.default_wallet_settings": "Default wallet settings",
Expand Down Expand Up @@ -1757,7 +1757,7 @@
"settings.onekey_lite_desc": "Restore your wallet without typing one word.",
"settings.onekey_wants_to_use_nfc": "\"OneKey\" wants to use NFC",
"settings.onekey_wants_to_use_nfc_desc": "To connect to OneKey Lite, NFC permissions are required.",
"settings.passcode_bypass": "passcode bypass",
"settings.passcode_bypass": "Passcode bypass",
"settings.passcode_bypass_desc": "When exceeding the allowed time of 2 hours, passcode verification is still required to ensure security.",
"settings.passkey": "PassKey",
"settings.password_bypass": "Password bypass",
Expand Down
12 changes: 6 additions & 6 deletions packages/shared/src/locale/json/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
"auth.new_password_form_label": "Nueva contraseña",
"auth.new_password_form_placeholder": "Crea una contraseña fuerte",
"auth.new_password_same_as_old": "La nueva contraseña debe ser diferente a la antigua",
"auth.passcode_cooldown": "Inténtalo de nuevo en {cooldowntime}",
"auth.passcode_cooldown": "Inténtalo de nuevo en {cooldowntime} min",
"auth.passcode_failed_alert": "{count} intentos fallidos más restablecerán el dispositivo",
"auth.passcode_set": "Código de acceso establecido",
"auth.passcode_set": "Conjunto de contraseñas",
"auth.password_set": "Contraseña establecida",
"auth.set_passcode": "Establecer código de acceso",
"auth.set_password": "Establecer contraseña",
Expand Down Expand Up @@ -1715,10 +1715,10 @@
"settings.clear_pending_transactions_desc": "Borre los datos pendientes en el registro del historial local.",
"settings.clear_successful": "Eliminación exitosa",
"settings.connected_sites": "Sitios conectados",
"settings.create_remove_wallets": "Crear / eliminar carteras sin contraseña",
"settings.create_remove_wallets_desc": "No se necesita contraseña para crear/eliminar carteras",
"settings.create_remove_wallets": "Crear/eliminar billeteras sin contraseña",
"settings.create_remove_wallets_desc": "No se necesita contraseña para crear o eliminar billeteras",
"settings.create_transactions": "Crear transacción sin contraseña",
"settings.create_transactions_desc": "No se necesita contraseña para las transacciones",
"settings.create_transactions_desc": "No se necesita contraseña para realizar transacciones",
"settings.cryptocurrency": "Criptomoneda",
"settings.default_currency": "Moneda predeterminada",
"settings.default_wallet_settings": "Configuración de billetera predeterminada",
Expand Down Expand Up @@ -1757,7 +1757,7 @@
"settings.onekey_lite_desc": "Restaura tu billetera sin escribir una sola palabra.",
"settings.onekey_wants_to_use_nfc": "\"OneKey\" quiere usar NFC",
"settings.onekey_wants_to_use_nfc_desc": "Para conectarse a OneKey Lite, se requieren permisos NFC.",
"settings.passcode_bypass": "omisión de código de acceso",
"settings.passcode_bypass": "Omisión de código de acceso",
"settings.passcode_bypass_desc": "Cuando se excede el tiempo permitido de 2 horas, aún se requiere la verificación del código de acceso para garantizar la seguridad.",
"settings.passkey": "Clave de acceso",
"settings.password_bypass": "Salto de contraseña",
Expand Down
10 changes: 5 additions & 5 deletions packages/shared/src/locale/json/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
"auth.new_password_form_label": "Nouveau mot de passe",
"auth.new_password_form_placeholder": "Créez un mot de passe fort",
"auth.new_password_same_as_old": "Le nouveau mot de passe doit être différent de l'ancien",
"auth.passcode_cooldown": "Réessayez dans {cooldowntime}",
"auth.passcode_cooldown": "Réessayez dans {cooldowntime} min",
"auth.passcode_failed_alert": "{count} tentatives échouées supplémentaires réinitialiseront l'appareil",
"auth.passcode_set": "Code d'accès défini",
"auth.passcode_set": "Ensemble de codes d'accès",
"auth.password_set": "Mot de passe défini",
"auth.set_passcode": "Définir le code d'accès",
"auth.set_password": "Définir le mot de passe",
Expand Down Expand Up @@ -1715,8 +1715,8 @@
"settings.clear_pending_transactions_desc": "Effacez les données en attente dans l'enregistrement de l'historique local.",
"settings.clear_successful": "Effacement réussi",
"settings.connected_sites": "Sites connectés",
"settings.create_remove_wallets": "Créer / supprimer des portefeuilles sans mot de passe",
"settings.create_remove_wallets_desc": "Aucun mot de passe nécessaire pour créer/supprimer des portefeuilles",
"settings.create_remove_wallets": "Créer/supprimer des portefeuilles sans mot de passe",
"settings.create_remove_wallets_desc": "Aucun mot de passe n'est nécessaire pour créer/supprimer des portefeuilles",
"settings.create_transactions": "Créer une transaction sans mot de passe",
"settings.create_transactions_desc": "Aucun mot de passe nécessaire pour les transactions",
"settings.cryptocurrency": "Crypto-monnaie",
Expand Down Expand Up @@ -1757,7 +1757,7 @@
"settings.onekey_lite_desc": "Restaurez votre portefeuille sans taper un seul mot.",
"settings.onekey_wants_to_use_nfc": "\"OneKey\" souhaite utiliser NFC",
"settings.onekey_wants_to_use_nfc_desc": "Pour se connecter à OneKey Lite, les permissions NFC sont requises.",
"settings.passcode_bypass": "contournement de code d'accès",
"settings.passcode_bypass": "Contournement du code d'accès",
"settings.passcode_bypass_desc": "Lorsqu'on dépasse le temps autorisé de 2 heures, la vérification du code d'accès est toujours requise pour garantir la sécurité.",
"settings.passkey": "Clé d’accès",
"settings.password_bypass": "Contournement de mot de passe",
Expand Down
12 changes: 6 additions & 6 deletions packages/shared/src/locale/json/hi_IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
"auth.new_password_form_label": "नया पासवर्ड",
"auth.new_password_form_placeholder": "एक मजबूत पासवर्ड बनाएं",
"auth.new_password_same_as_old": "नया पासवर्ड पुराने से अलग होना चाहिए",
"auth.passcode_cooldown": "{cooldowntime} में फिर से प्रयास करें",
"auth.passcode_cooldown": "{cooldowntime} मिनट में फिर से प्रयास करें",
"auth.passcode_failed_alert": "{count} और असफल प्रयास डिवाइस को रीसेट कर देंगे",
"auth.passcode_set": "पासकोड सेट",
"auth.passcode_set": "पासकोड सेट करें",
"auth.password_set": "पासवर्ड सेट",
"auth.set_passcode": "पासकोड सेट करें",
"auth.set_password": "पासवर्ड सेट करें",
Expand Down Expand Up @@ -1715,10 +1715,10 @@
"settings.clear_pending_transactions_desc": "स्थानीय इतिहास रिकॉर्ड में लंबित डेटा साफ़ करें।",
"settings.clear_successful": "सफलतापूर्वक साफ करें",
"settings.connected_sites": "जुड़े हुए साइट",
"settings.create_remove_wallets": "पासवर्ड के बिना वॉलेट बनाएं / हटाएं",
"settings.create_remove_wallets_desc": "वॉलेट बनाने/हटाने के लिए कोई पासवर्ड की आवश्यकता नहीं है",
"settings.create_transactions": "पासवर्ड के बिना लेन-देन बनाएं",
"settings.create_transactions_desc": "लेन-देन के लिए कोई पासवर्ड की आवश्यकता नहीं है",
"settings.create_remove_wallets": "पासकोड के बिना वॉलेट बनाएं / हटाएं",
"settings.create_remove_wallets_desc": "वॉलेट बनाने/हटाने के लिए किसी पासकोड की आवश्यकता नहीं",
"settings.create_transactions": "बिना पासवर्ड के लेनदेन बनाएं",
"settings.create_transactions_desc": "लेन-देन के लिए किसी पासकोड की आवश्यकता नहीं",
"settings.cryptocurrency": "cryptocurrency",
"settings.default_currency": "मूल विमुद्रण",
"settings.default_wallet_settings": "डिफ़ॉल्ट वॉलेट सेटिंग्स",
Expand Down
Loading

0 comments on commit 83441f4

Please sign in to comment.