Skip to content

Commit

Permalink
opt.: switch to previous chat after deleting a chat (#26) (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit authored Jun 15, 2024
1 parent eaa557f commit e189e55
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 208;
CURRENT_PROJECT_VERSION = 209;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand Down Expand Up @@ -494,7 +494,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 208;
CURRENT_PROJECT_VERSION = 209;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand All @@ -519,7 +519,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 208;
CURRENT_PROJECT_VERSION = 209;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand Down
5 changes: 1 addition & 4 deletions lib/data/res/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@

class Build {
static const String name = "GPTBox";
static const int build = 208;
static const String engine = "3.22.2";
static const String buildAt = "2024-06-12 21:35:08";
static const int modifications = 6;
static const int build = 209;
}
30 changes: 22 additions & 8 deletions lib/view/page/home/ctrl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,29 @@ void _switchChat([String? id]) {
}

void _switchPreviousChat() {
final idx = _allHistories.keys.toList().indexOf(_curChatId);
if (idx < 0 || idx >= _allHistories.length - 1) return;
_switchChat(_allHistories.keys.elementAt(idx + 1));
final iter = _allHistories.keys.iterator;
bool next = false;
while (iter.moveNext()) {
if (next) {
_switchChat(iter.current);
return;
}
if (iter.current == _curChatId) next = true;
}
}

void _switchNextChat() {
final idx = _allHistories.keys.toList().indexOf(_curChatId);
if (idx <= 0) return;
_switchChat(_allHistories.keys.elementAt(idx - 1));
final iter = _allHistories.keys.iterator;
String? last;
while (iter.moveNext()) {
if (iter.current == _curChatId) {
if (last != null) {
_switchChat(last);
return;
}
}
last = iter.current;
}
}

void _storeChat(
Expand Down Expand Up @@ -145,10 +159,10 @@ void _onTapDeleteChat(String chatId, BuildContext context) {

void _onDeleteChat(String chatId) {
Stores.history.delete(chatId);
_allHistories.remove(chatId);
if (_curChatId == chatId) {
_switchChat();
_switchPreviousChat();
}
_allHistories.remove(chatId);
_historyRN.build();
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ packages:
dependency: "direct dev"
description:
path: "."
ref: "v1.0.17"
resolved-ref: bcb7019cc8bb3ab8c9c36653cd13936909c6e075
ref: "v1.0.24"
resolved-ref: b7e3698aa0ad2fcf0629d140b134276b9e42dac0
url: "https://github.com/lppcg/fl_build.git"
source: git
version: "1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: gpt_box
description: "A third-party GPT Client for OpenAI API."
publish_to: 'none'
version: 1.0.209+209
version: 1.0.210+210

environment:
sdk: '>=3.3.0 <4.0.0'
Expand Down Expand Up @@ -45,7 +45,7 @@ dev_dependencies:
fl_build:
git:
url: https://github.com/lppcg/fl_build.git
ref: v1.0.17
ref: v1.0.24
# path: ../fl_build

flutter:
Expand Down

0 comments on commit e189e55

Please sign in to comment.