mirror of
https://ghfast.top/https://github.com/discourse/discourse-ai.git
synced 2026-07-16 11:36:23 +08:00
## 🔍 Overview
When the title suggestions return no suggestions, there is no indication in the UI. In the tag suggester we show a toast when there aren't any suggestions but the request was a success. In this update we make a similar UI indication with a toast for both category and title suggestions. Additionally, for all suggestions we add a "Try again" button to the toast so that suggestions can be generated again if the results yield nothing the first time.
34 lines
916 B
JavaScript
34 lines
916 B
JavaScript
import { getOwner } from "@ember/application";
|
|
import { later } from "@ember/runloop";
|
|
import { i18n } from "discourse-i18n";
|
|
|
|
export const MIN_CHARACTER_COUNT = 40;
|
|
|
|
export function showSuggestionsError(context, reloadFn) {
|
|
const toasts = getOwner(context).lookup("service:toasts");
|
|
|
|
toasts.error({
|
|
class: "ai-suggestion-error",
|
|
duration: "long",
|
|
showProgressBar: true,
|
|
data: {
|
|
message: i18n("discourse_ai.ai_helper.suggest_errors.no_suggestions"),
|
|
actions: [
|
|
{
|
|
label: i18n("discourse_ai.ai_helper.context_menu.regen"),
|
|
icon: "rotate",
|
|
class: "btn btn-small",
|
|
action: async (toast) => {
|
|
toast.close();
|
|
|
|
await reloadFn();
|
|
|
|
if (context.dMenu?.show && context.suggestions?.length > 0) {
|
|
later(() => context.dMenu.show(), 50);
|
|
}
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|
|
}
|