@@ -63,36 +63,44 @@ export class ChatContainer {
6363 this . messageStore . subscribe ( this . updateMessages . bind ( this ) ) ;
6464 }
6565
66- private updateMessages ( message : Message [ ] ) {
67- const currentIndex = this . plugin . settings . currentIndex ;
68- const fabIndex = this . plugin . settings . fabSettings . historyIndex ;
69- const widgetIndex = this . plugin . settings . widgetSettings . historyIndex ;
70-
71- if ( currentIndex > - 1 ) {
72- message = this . plugin . settings . promptHistory [ currentIndex ] . messages ;
73- }
74-
75- // Always update the current view
76- if ( this . viewType === this . plugin . settings . currentView ) {
77- this . resetChat ( ) ;
78- this . generateIMLikeMessages ( message ) ;
79- return ;
80- }
81-
82- // Update FAB view if it's showing the same history item
83- if ( this . viewType === "floating-action-button" && fabIndex === currentIndex && currentIndex > - 1 ) {
84- this . resetChat ( ) ;
85- this . generateIMLikeMessages ( message ) ;
86- return ;
87- }
88-
89- // Update Widget view if it's showing the same history item
90- if ( this . viewType === "widget" && widgetIndex === currentIndex && currentIndex > - 1 ) {
91- this . resetChat ( ) ;
92- this . generateIMLikeMessages ( message ) ;
93- return ;
94- }
95- }
66+ private updateMessages ( message : Message [ ] ) {
67+ const currentIndex = this . plugin . settings . currentIndex ;
68+ const fabIndex = this . plugin . settings . fabSettings . historyIndex ;
69+ const widgetIndex = this . plugin . settings . widgetSettings . historyIndex ;
70+
71+ if ( currentIndex > - 1 ) {
72+ message = this . plugin . settings . promptHistory [ currentIndex ] . messages ;
73+ }
74+
75+ // Always update the current view
76+ if ( this . viewType === this . plugin . settings . currentView ) {
77+ this . resetChat ( ) ;
78+ this . generateIMLikeMessages ( message ) ;
79+ return ;
80+ }
81+
82+ // Update FAB view if it's showing the same history item
83+ if (
84+ this . viewType === "floating-action-button" &&
85+ fabIndex === currentIndex &&
86+ currentIndex > - 1
87+ ) {
88+ this . resetChat ( ) ;
89+ this . generateIMLikeMessages ( message ) ;
90+ return ;
91+ }
92+
93+ // Update Widget view if it's showing the same history item
94+ if (
95+ this . viewType === "widget" &&
96+ widgetIndex === currentIndex &&
97+ currentIndex > - 1
98+ ) {
99+ this . resetChat ( ) ;
100+ this . generateIMLikeMessages ( message ) ;
101+ return ;
102+ }
103+ }
96104
97105 getMessages ( ) {
98106 return this . messageStore . getMessages ( ) ;
@@ -792,6 +800,7 @@ private updateMessages(message: Message[]) {
792800 messages . pop ( ) ;
793801 this . messageStore . setMessages ( messages ) ;
794802 this . historyMessages . lastElementChild ?. remove ( ) ;
803+ this . plugin . history . update ( this . plugin . settings . currentIndex , messages ) ;
795804 }
796805
797806 removeMessage ( header : Header , modelName : string ) {
0 commit comments