Skip to content

Commit

Permalink
Optimize chatgpt plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
qianlifeng committed Dec 13, 2023
1 parent fa9d49d commit 1c6e3b3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 11 deletions.
9 changes: 9 additions & 0 deletions Wox.UI.Flutter/wox/lib/entity/wox_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ class WoxImage {
return data;
}

@override
int get hashCode => imageType.hashCode ^ imageData.hashCode;

@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is WoxImage && other.imageType == imageType && other.imageData == imageData;
}

static WoxImage? parse(String imageData) {
//split image data with : to get image type, only get first part
final List<String> imageDataList = imageData.split(':');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,16 +452,37 @@ class WoxLauncherController extends GetxController implements WoxLauncherInterfa
void onRefreshResult(WoxRefreshableResult result) {
for (var i = 0; i < queryResults.length; i++) {
if (queryResults[i].id == result.resultId) {
queryResults[i].title = result.title;
queryResults[i].subTitle = result.subTitle;
queryResults[i].icon = result.icon;
queryResults[i].preview = result.preview;
queryResults[i].contextData = result.contextData;
queryResults[i].refreshInterval = result.refreshInterval;
var hasAnyChange = false;
if (queryResults[i].title != result.title) {
queryResults[i].title = result.title;
hasAnyChange = true;
}
if (queryResults[i].subTitle != result.subTitle) {
queryResults[i].subTitle = result.subTitle;
hasAnyChange = true;
}
if (queryResults[i].icon != result.icon) {
queryResults[i].icon = result.icon;
hasAnyChange = true;
}
if (queryResults[i].preview != result.preview) {
queryResults[i].preview = result.preview;
currentPreview.value = result.preview;
hasAnyChange = false;
}
if (queryResults[i].contextData != result.contextData) {
queryResults[i].contextData = result.contextData;
hasAnyChange = true;
}
if (queryResults[i].refreshInterval != result.refreshInterval) {
queryResults[i].refreshInterval = result.refreshInterval;
hasAnyChange = true;
}

currentPreview.value = result.preview;
if (hasAnyChange) {
queryResults.refresh();
}

queryResults.refresh();
break;
}
}
Expand Down
11 changes: 8 additions & 3 deletions Wox/plugin/system/chatgpt.go

Large diffs are not rendered by default.

0 comments on commit 1c6e3b3

Please sign in to comment.