From 47df2a8a7ac9c206996b5352cf734bdb03ccd902 Mon Sep 17 00:00:00 2001 From: detherminal <76167420+detherminal@users.noreply.github.com> Date: Fri, 5 May 2023 20:30:22 +0300 Subject: [PATCH] feat: use isar instead of hive --- .../advanced_views/manage_explorer_view.dart | 5 +++-- lib/utilities/block_explorers.dart | 22 +++++++------------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart b/lib/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart index 1eb48a757..dc84fe8c8 100644 --- a/lib/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart +++ b/lib/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart @@ -88,8 +88,9 @@ class _ManageExplorerViewState extends ConsumerState { .getPrimaryEnabledButtonStyle(context), onPressed: () { textEditingController.text = textEditingController.text.trim(); - setBlockExplorerForCoin(coin: widget.coin, url: Uri.parse(textEditingController.text)); - Navigator.of(context).pop(); + setBlockExplorerForCoin(coin: widget.coin, url: Uri.parse(textEditingController.text)).then((value) => + Navigator.of(context).pop() + ); }, child: Text( "Save", diff --git a/lib/utilities/block_explorers.dart b/lib/utilities/block_explorers.dart index 8130626b8..ebfee9db0 100644 --- a/lib/utilities/block_explorers.dart +++ b/lib/utilities/block_explorers.dart @@ -3,6 +3,8 @@ import 'dart:ffi'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import '../db/hive/db.dart'; +import '../db/isar/main_db.dart'; +import '../models/isar/models/block_explorer.dart'; Uri getDefaultBlockExplorerUrlFor({ required Coin coin, @@ -46,14 +48,10 @@ Uri getDefaultBlockExplorerUrlFor({ } } -int setBlockExplorerForCoin( +Future setBlockExplorerForCoin( {required Coin coin, required Uri url} - ) { - var ticker = coin.ticker; - DB.instance.put( - boxName: DB.boxNameAllWalletsData, - key: "${ticker}blockExplorerUrl", - value: url); + ) async { + await MainDB.instance.putTransactionBlockExplorer(TransactionBlockExplorer(ticker: coin.ticker, url: url.toString())); return 0; } @@ -61,15 +59,11 @@ Uri getBlockExplorerTransactionUrlFor({ required Coin coin, required String txid, }) { - var ticker = coin.ticker; - var url = DB.instance.get( - boxName: DB.boxNameAllWalletsData, - key: "${ticker}blockExplorerUrl", - ); + var url = MainDB.instance.getTransactionBlockExplorer(coin: coin)?.url.toString(); if (url == null) { return getDefaultBlockExplorerUrlFor(coin: coin, txid: txid); } else { - url = url.replace("%5BTXID%5D", txid); - return Uri.parse(url.toString()); + url = url.replaceAll("%5BTXID%5D", txid); + return Uri.parse(url); } }