Skip to content

Commit

Permalink
(replay) fix: load img (#210)
Browse files Browse the repository at this point in the history
Fixes #208
  • Loading branch information
lollipopkit authored Jan 9, 2025
1 parent b2f7966 commit 388f3bb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
4 changes: 4 additions & 0 deletions lib/data/model/chat/history/history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/data/res/openai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> updateModels({
bool force = false,
bool diffUrl = false,
Expand Down
11 changes: 5 additions & 6 deletions lib/view/page/home/req.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 388f3bb

Please sign in to comment.