Skip to content

Commit 9c60da8

Browse files
committed
Fix
1 parent f756707 commit 9c60da8

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • llm/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/ui/viewmodel

llm/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/ui/viewmodel/ChatViewModel.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ class ChatViewModel(application: Application) : AndroidViewModel(application), L
8686
val moduleSettings = demoSharedPreferences.getModuleSettings()
8787
if (moduleSettings.isClearChatHistory) {
8888
// Clear the flag and don't load messages
89+
// Keep isLoadModel flag so model still loads in checkAndLoadSettings()
8990
demoSharedPreferences.removeExistingMessages()
9091
demoSharedPreferences.saveModuleSettings(moduleSettings.copy(isClearChatHistory = false))
91-
currentSettingsFields = moduleSettings.copy(isClearChatHistory = false)
92+
// Don't update currentSettingsFields here - let checkAndLoadSettings() handle it
93+
// so it detects the change and loads the model if needed
9294
} else {
9395
loadSavedMessages()
9496
}
@@ -102,7 +104,7 @@ class ChatViewModel(application: Application) : AndroidViewModel(application), L
102104
demoSharedPreferences.removeExistingMessages()
103105
return
104106
}
105-
107+
106108
val existingMsgJSON = demoSharedPreferences.getSavedMessages()
107109
if (existingMsgJSON.isNotEmpty()) {
108110
val gson = Gson()

0 commit comments

Comments
 (0)