From 1194a87c76ad40237adea16b92f0d189a4de7337 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Sun, 24 Sep 2023 14:51:51 +0800 Subject: [PATCH] fix - fix: same name snippet caused err - fix: auto load servers from db after restoring --- ios/Runner.xcodeproj/project.pbxproj | 36 ++++++------- lib/data/provider/server.dart | 4 +- lib/data/provider/snippet.dart | 2 +- lib/data/res/build_data.dart | 8 +-- lib/view/page/ping.dart | 11 +--- lib/view/page/server/tab.dart | 6 +-- lib/view/page/setting/entry.dart | 74 ++++++++++++++------------ lib/view/page/snippet/list.dart | 2 +- macos/Runner.xcodeproj/project.pbxproj | 12 ++--- 9 files changed, 74 insertions(+), 81 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 4649fddd..03867cb6 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -586,7 +586,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -596,7 +596,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -720,7 +720,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -730,7 +730,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -748,7 +748,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -758,7 +758,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -779,7 +779,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -792,7 +792,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; @@ -818,7 +818,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -831,7 +831,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -854,7 +854,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -867,7 +867,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -890,7 +890,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -902,7 +902,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; @@ -931,7 +931,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -943,7 +943,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; @@ -969,7 +969,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -981,7 +981,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; diff --git a/lib/data/provider/server.dart b/lib/data/provider/server.dart index a092e5d9..65273848 100644 --- a/lib/data/provider/server.dart +++ b/lib/data/provider/server.dart @@ -42,8 +42,8 @@ class ServerProvider extends ChangeNotifier { _serverOrder.clear(); final spis = Stores.server.fetch(); - for (final spi in spis) { - _servers[spi.id] = genServer(spi); + for (int idx = 0; idx < spis.length; idx++) { + _servers[spis[idx].id] = genServer(spis[idx]); } final serverOrder_ = Stores.setting.serverOrder.fetch(); if (serverOrder_.isNotEmpty) { diff --git a/lib/data/provider/snippet.dart b/lib/data/provider/snippet.dart index 38e757d0..bb320dfb 100644 --- a/lib/data/provider/snippet.dart +++ b/lib/data/provider/snippet.dart @@ -31,7 +31,7 @@ class SnippetProvider extends ChangeNotifier { } void _addInternal() { - if (!Stores.setting.fTISBM.fetch()) { + if (!Stores.setting.fTISBM.fetch() || _snippets.isNotEmpty) { return; } _snippets.add(installSBM); diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 78af7520..27c7fa27 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 570; + static const int build = 572; static const String engine = "3.13.5"; - static const String buildAt = "2023-09-21 10:20:10"; - static const int modifications = 4; - static const int script = 17; + static const String buildAt = "2023-09-23 11:12:55"; + static const int modifications = 2; + static const int script = 18; } diff --git a/lib/view/page/ping.dart b/lib/view/page/ping.dart index e053f8ec..b0ece9d3 100644 --- a/lib/view/page/ping.dart +++ b/lib/view/page/ping.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:after_layout/after_layout.dart'; import 'package:flutter/material.dart'; import 'package:toolbox/core/extension/context/common.dart'; import 'package:toolbox/core/extension/context/dialog.dart'; @@ -28,7 +27,7 @@ class PingPage extends StatefulWidget { } class _PingPageState extends State - with AutomaticKeepAliveClientMixin, AfterLayoutMixin { + with AutomaticKeepAliveClientMixin { late TextEditingController _textEditingController; final _results = ValueNotifier([]); bool get isInit => _results.value.isEmpty; @@ -194,12 +193,4 @@ class _PingPageState extends State @override bool get wantKeepAlive => true; - - @override - Future> afterFirstLayout(BuildContext context) async { - if (Providers.server.serverOrder.isEmpty) { - await Providers.server.loadLocalData(); - await Providers.server.refreshData(); - } - } } diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index 5a8f863a..a7671700 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -456,9 +456,7 @@ class _ServerPageState extends State @override Future afterFirstLayout(BuildContext context) async { await GetIt.I.allReady(); - if (Providers.server.serverOrder.isEmpty) { - await Providers.server.loadLocalData(); - } + await Providers.server.loadLocalData(); Providers.server.startAutoRefresh(); } @@ -505,7 +503,7 @@ class _ServerPageState extends State return 23.0; } if (_flipedCardIds.contains(id)) { - return 77.0; + return 80.0; } if (Stores.setting.moveOutServerTabFuncBtns.fetch() && // Discussion #146 diff --git a/lib/view/page/setting/entry.dart b/lib/view/page/setting/entry.dart index 1a9d42b9..be0357b4 100644 --- a/lib/view/page/setting/entry.dart +++ b/lib/view/page/setting/entry.dart @@ -100,42 +100,46 @@ class _SettingPageState extends State { appBar: CustomAppBar( title: Text(l10n.setting), actions: [ - IconButton( - onPressed: () => context.showRoundDialog( - title: Text(l10n.attention), - child: Text(l10n.sureDelete(l10n.all)), - actions: [ - TextButton( - onPressed: () { - _setting.box.deleteAll(_setting.box.keys); - context.pop(); - context.showSnackBar(l10n.success); - }, - child: - Text(l10n.ok, style: const TextStyle(color: Colors.red)), - ), - ], + Padding( + padding: const EdgeInsets.only(right: 17), + child: InkWell( + onTap: () => context.showRoundDialog( + title: Text(l10n.attention), + child: Text(l10n.sureDelete(l10n.all)), + actions: [ + TextButton( + onPressed: () { + _setting.box.deleteAll(_setting.box.keys); + context.pop(); + context.showSnackBar(l10n.success); + }, + child: Text(l10n.ok, + style: const TextStyle(color: Colors.red)), + ), + ], + ), + /// Only for debug, this will cause the app to crash + // onDoubleTap: () => context.showRoundDialog( + // title: Text(l10n.attention), + // child: Text(l10n.sureDelete(l10n.all)), + // actions: [ + // TextButton( + // onPressed: () { + // Stores.docker.box.deleteFromDisk(); + // Stores.server.box.deleteFromDisk(); + // Stores.setting.box.deleteFromDisk(); + // Stores.history.box.deleteFromDisk(); + // Stores.snippet.box.deleteFromDisk(); + // Stores.key.box.deleteFromDisk(); + // exit(0); + // }, + // child: Text(l10n.ok, + // style: const TextStyle(color: Colors.red)), + // ), + // ], + // ), + child: const Icon(Icons.delete), ), - // onDoubleTap: () => context.showRoundDialog( - // title: Text(l10n.attention), - // child: Text(l10n.sureDelete(l10n.all)), - // actions: [ - // TextButton( - // onPressed: () { - // Stores.docker.box.deleteFromDisk(); - // Stores.server.box.deleteFromDisk(); - // Stores.setting.box.deleteFromDisk(); - // Stores.history.box.deleteFromDisk(); - // Stores.snippet.box.deleteFromDisk(); - // Stores.key.box.deleteFromDisk(); - // context.pop(); - // context.showSnackBar(l10n.success); - // }, - // child: Text(l10n.ok, style: const TextStyle(color: Colors.red)), - // ), - // ], - // ), - icon: const Icon(Icons.delete), ), ], ), diff --git a/lib/view/page/snippet/list.dart b/lib/view/page/snippet/list.dart index b6c458ab..99e60065 100644 --- a/lib/view/page/snippet/list.dart +++ b/lib/view/page/snippet/list.dart @@ -83,7 +83,7 @@ class _SnippetListPageState extends State { itemBuilder: (context, idx) { final snippet = filtered.elementAt(idx); return ReorderableDelayedDragStartListener( - key: ValueKey(snippet.name), + key: ValueKey(idx), index: idx, child: _buildSnippetItem(snippet), ); diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 357f777f..db576d78 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -476,9 +476,9 @@ baseConfigurationReference = C1C758C41C4E208965A68933 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -491,9 +491,9 @@ baseConfigurationReference = 15AF97DF993E8968098D6EBE /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -506,9 +506,9 @@ baseConfigurationReference = 7CFA7DE7FABA75685DFB6948 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 570; + CURRENT_PROJECT_VERSION = 572; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.570; + MARKETING_VERSION = 1.0.572; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0;