@@ -13,24 +13,23 @@ interface State {
1313 currentChatId : string | null ;
1414 selectedModel : string | null ;
1515 userName : string | "Anonymous" ;
16- isDownloading : boolean ; // New: Track download state
17- downloadProgress : number ; // New: Track download progress
18- downloadingModel : string | null ; // New: Track which model is being downloaded
16+ isDownloading : boolean ;
17+ downloadProgress : number ;
18+ downloadingModel : string | null ;
1919}
2020
2121interface Actions {
2222 setBase64Images : ( base64Images : string [ ] | null ) => void ;
23- setMessages : ( chatId : string , fn : ( messages : Message [ ] ) => Message [ ] ) => void ;
2423 setCurrentChatId : ( chatId : string ) => void ;
2524 setSelectedModel : ( selectedModel : string ) => void ;
2625 getChatById : ( chatId : string ) => ChatSession | undefined ;
2726 getMessagesById : ( chatId : string ) => Message [ ] ;
2827 saveMessages : ( chatId : string , messages : Message [ ] ) => void ;
2928 handleDelete : ( chatId : string , messageId ?: string ) => void ;
3029 setUserName : ( userName : string ) => void ;
31- startDownload : ( modelName : string ) => void ; // New: Start download
32- stopDownload : ( ) => void ; // New: Stop download
33- setDownloadProgress : ( progress : number ) => void ; // New: Update progress
30+ startDownload : ( modelName : string ) => void ;
31+ stopDownload : ( ) => void ;
32+ setDownloadProgress : ( progress : number ) => void ;
3433}
3534
3635const useChatStore = create < State & Actions > ( ) (
@@ -41,29 +40,13 @@ const useChatStore = create<State & Actions>()(
4140 currentChatId : null ,
4241 selectedModel : null ,
4342 userName : "Anonymous" ,
44- isDownloading : false , // Default download state
45- downloadProgress : 0 , // Default progress
46- downloadingModel : null , // Default downloading model
43+ isDownloading : false ,
44+ downloadProgress : 0 ,
45+ downloadingModel : null ,
4746
48- // Existing actions
4947 setBase64Images : ( base64Images ) => set ( { base64Images } ) ,
5048 setUserName : ( userName ) => set ( { userName } ) ,
51- setMessages : ( chatId , fn ) =>
52- set ( ( state ) => {
53- const existingChat = state . chats [ chatId ] ;
54- const updatedMessages = fn ( existingChat ?. messages || [ ] ) ;
5549
56- return {
57- chats : {
58- ...state . chats ,
59- [ chatId ] : {
60- ...existingChat ,
61- messages : updatedMessages ,
62- createdAt : existingChat ?. createdAt || new Date ( ) . toISOString ( ) ,
63- } ,
64- } ,
65- } ;
66- } ) ,
6750 setCurrentChatId : ( chatId ) => set ( { currentChatId : chatId } ) ,
6851 setSelectedModel : ( selectedModel ) => set ( { selectedModel } ) ,
6952 getChatById : ( chatId ) => {
@@ -118,7 +101,6 @@ const useChatStore = create<State & Actions>()(
118101 } ) ;
119102 } ,
120103
121- // New actions for download state
122104 startDownload : ( modelName ) =>
123105 set ( { isDownloading : true , downloadingModel : modelName , downloadProgress : 0 } ) ,
124106 stopDownload : ( ) =>
0 commit comments