discourse-ai/assets/javascripts/discourse/services/discobot-discoveries.js
Keegan George bb32d0d737
FEATURE: Add ability to disable search discoveries (#1177)
This update adds the ability to disable search discoveries. This can be done through a tooltip when search discoveries are shown. It can also be done in the AI user preferences, which has also been updated to accommodate more than just the one image caption setting.
2025-03-10 14:17:58 -07:00

27 lines
753 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 = "";
resetDiscovery() {
this.discovery = "";
this.discoveryTimedOut = false;
this.modelUsed = "";
}
@action
async disableDiscoveries() {
this.currentUser.user_option.ai_search_discoveries = false;
await this.currentUser.save(["ai_search_discoveries"]);
location.reload();
}
}