mirror of
https://ghfast.top/https://github.com/discourse/discourse-ai.git
synced 2026-07-16 11:36:23 +08:00
This update fixes a few small quirks with Discobot discoveries: - [X] subsequent searches should work correctly - [X] discovery timeout should maintain UI - [X] key up/down traversal of regular search results should still work
37 lines
980 B
JavaScript
37 lines
980 B
JavaScript
import { tracked } from "@glimmer/tracking";
|
|
import { action } from "@ember/object";
|
|
import Service, { service } from "@ember/service";
|
|
|
|
export default class DiscobotDiscoveries extends Service {
|
|
// We use this to retain state after search menu gets closed.
|
|
// Similar to discourse/discourse#25504
|
|
@service currentUser;
|
|
|
|
@tracked discovery = "";
|
|
@tracked lastQuery = "";
|
|
@tracked discoveryTimedOut = false;
|
|
@tracked modelUsed = "";
|
|
@tracked loadingDiscoveries = false;
|
|
|
|
resetDiscovery() {
|
|
this.loadingDiscoveries = false;
|
|
this.discovery = "";
|
|
this.discoveryTimedOut = false;
|
|
this.modelUsed = "";
|
|
}
|
|
|
|
get showDiscoveryTitle() {
|
|
return (
|
|
this.discovery.length > 0 ||
|
|
this.loadingDiscoveries ||
|
|
this.discoveryTimedOut
|
|
);
|
|
}
|
|
|
|
@action
|
|
async disableDiscoveries() {
|
|
this.currentUser.user_option.ai_search_discoveries = false;
|
|
await this.currentUser.save(["ai_search_discoveries"]);
|
|
location.reload();
|
|
}
|
|
}
|