diff --git a/lib/data/model/chat/history/history.dart b/lib/data/model/chat/history/history.dart index 17d212e..7302271 100644 --- a/lib/data/model/chat/history/history.dart +++ b/lib/data/model/chat/history/history.dart @@ -112,6 +112,10 @@ enum ChatContentType { @HiveField(2) image, ; + + bool get isText => this == text; + bool get isAudio => this == audio; + bool get isImage => this == image; } @HiveType(typeId: 2) diff --git a/lib/data/res/openai.dart b/lib/data/res/openai.dart index bcabe14..c2247be 100644 --- a/lib/data/res/openai.dart +++ b/lib/data/res/openai.dart @@ -52,7 +52,7 @@ abstract final class Cfg { /// Update models list /// - [force] force update, ignore cache /// - [diffUrl] abbreviation for `isDifferentUrl`. - /// if true, not set [models.value] to empty list if failed + /// if true, skip setting [models.value] to empty list if failed static Future updateModels({ bool force = false, bool diffUrl = false, diff --git a/lib/view/page/home/req.dart b/lib/view/page/home/req.dart index a7fa933..b2f2439 100644 --- a/lib/view/page/home/req.dart +++ b/lib/view/page/home/req.dart @@ -545,11 +545,8 @@ void _onReplay({ } chatHistory.items.removeRange(replayMsgIdx, chatHistory.items.length); - final text = - item.content.firstWhereOrNull((e) => e.type == ChatContentType.text)?.raw; - final img = item.content - .firstWhereOrNull((e) => e.type == ChatContentType.image) - ?.raw; + final text = item.content.firstWhereOrNull((e) => e.type.isText)?.raw; + final img = item.content.firstWhereOrNull((e) => e.type.isImage)?.raw; if (text == null) { final msg = 'Replay Chat($chatId) item($item) text is null'; @@ -559,7 +556,9 @@ void _onReplay({ } _inputCtrl.text = text; - _filePicked.value = img != null ? await _FilePicked.fromUrl(img) : null; + await context.showLoadingDialog(fn: () async { + _filePicked.value = img != null ? await _FilePicked.fromUrl(img) : null; + }); _onCreateRequest(context, chatId); } diff --git a/pubspec.lock b/pubspec.lock index f81d0a4..e5a1d9a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -468,8 +468,8 @@ packages: dependency: "direct main" description: path: "." - ref: "v1.0.230" - resolved-ref: d0d7826ab9ed8bd47433bbb2147c203c3d502bcb + ref: "v1.0.231" + resolved-ref: "7371470adbfd105aae686c9d3aca7a6353d04e87" url: "https://github.com/lppcg/fl_lib" source: git version: "0.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index fc02f13..458e8bf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,7 +40,7 @@ dependencies: fl_lib: git: url: https://github.com/lppcg/fl_lib - ref: v1.0.230 + ref: v1.0.231 dependency_overrides: # fl_lib: