@@ -3,6 +3,7 @@ import { TrackedArray } from "@ember-compat/tracked-built-ins";
33import { ajax } from "discourse/lib/ajax" ;
44import { bind } from "discourse/lib/decorators" ;
55import { withPluginApi } from "discourse/lib/plugin-api" ;
6+ import { i18n } from "discourse-i18n" ;
67import AiBotSidebarNewConversation from "../discourse/components/ai-bot-sidebar-new-conversation" ;
78import { isPostFromAiBot } from "../discourse/lib/ai-bot-helper" ;
89import { 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 ) ;
0 commit comments