Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 97b74d1

Browse files
committed
DEV: Add locale
1 parent 924f9cd commit 97b74d1

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

assets/javascripts/initializers/ai-conversations-sidebar.js

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { TrackedArray } from "@ember-compat/tracked-built-ins";
33
import { ajax } from "discourse/lib/ajax";
44
import { bind } from "discourse/lib/decorators";
55
import { withPluginApi } from "discourse/lib/plugin-api";
6+
import { i18n } from "discourse-i18n";
67
import AiBotSidebarNewConversation from "../discourse/components/ai-bot-sidebar-new-conversation";
78
import { isPostFromAiBot } from "../discourse/lib/ai-bot-helper";
89
import { AI_CONVERSATIONS_PANEL } from "../discourse/services/ai-conversations-sidebar-manager";
@@ -97,9 +98,9 @@ export default {
9798
}
9899

99100
get text() {
100-
// TODO: FIX
101-
//return i18n(themePrefix("messages_sidebar.title"));
102-
return "Conversations";
101+
return i18n(
102+
"discourse_ai.ai_bot.conversations.min_input_length_message"
103+
);
103104
}
104105

105106
get sidebarElement() {
@@ -148,33 +149,35 @@ export default {
148149
}
149150
}
150151

151-
fetchMessages(isLoadingMore = false) {
152+
async fetchMessages(isLoadingMore = false) {
152153
if (this.isFetching) {
153154
return;
154155
}
155156

156-
this.isFetching = true;
157-
158-
ajax("/discourse-ai/ai-bot/conversations.json", {
159-
data: { page: this.page, per_page: 40 },
160-
})
161-
.then((data) => {
162-
if (isLoadingMore) {
163-
this.topics = [...this.topics, ...data.conversations];
164-
} else {
165-
this.topics = data.conversations;
157+
try {
158+
this.isFetching = true;
159+
const data = await ajax(
160+
"/discourse-ai/ai-bot/conversations.json",
161+
{
162+
data: { page: this.page, per_page: 40 },
166163
}
164+
);
167165

168-
this.totalTopicsCount = data.meta.total;
169-
this.hasMore = data.meta.more;
170-
this.isFetching = false;
171-
this.removeScrollListener();
172-
this.buildSidebarLinks();
173-
this.attachScrollListener();
174-
})
175-
.catch(() => {
176-
this.isFetching = false;
177-
});
166+
if (isLoadingMore) {
167+
this.topics = [...this.topics, ...data.conversations];
168+
} else {
169+
this.topics = data.conversations;
170+
}
171+
172+
this.totalTopicsCount = data.meta.total;
173+
this.hasMore = data.meta.more;
174+
this.isFetching = false;
175+
this.removeScrollListener();
176+
this.buildSidebarLinks();
177+
this.attachScrollListener();
178+
} catch {
179+
this.isFetching = false;
180+
}
178181
}
179182

180183
loadMore() {
@@ -207,6 +210,7 @@ export default {
207210
}
208211

209212
updateTopicTitle(topicId, title) {
213+
// update the topic title in the sidebar, instead of the default title
210214
const text = document.querySelector(
211215
`.sidebar-section-link-wrapper .ai-conversation-${topicId} .sidebar-section-link-content-text`
212216
);

config/locales/client.en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ en:
711711
placeholder: "Ask a question..."
712712
new: "New Question"
713713
min_input_length_message: "Message must be longer than 10 characters"
714+
messages_sidebar_title: "Conversations"
714715
sentiments:
715716
dashboard:
716717
title: "Sentiment"

0 commit comments

Comments
 (0)