Skip to content

Commit b03510c

Browse files
Fix issues
1 parent dc8aa12 commit b03510c

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

Recap/UseCases/Settings/Components/TabViews/GeneralSettingsView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct GeneralSettingsView<ViewModel: GeneralSettingsViewModelType>: View {
9090
VStack(alignment: .leading, spacing: 12) {
9191
CustomTextEditor(
9292
title: "Prompt Template",
93-
text: viewModel.customPromptTemplate,
93+
text: $viewModel.customPromptTemplate,
9494
placeholder: "Enter your custom prompt template here...",
9595
height: 120
9696
)
@@ -178,9 +178,14 @@ struct GeneralSettingsView<ViewModel: GeneralSettingsViewModelType>: View {
178178
}
179179

180180
private final class PreviewGeneralSettingsViewModel: GeneralSettingsViewModelType {
181+
func updateCustomPromptTemplate(_ template: String) async {}
182+
183+
func resetToDefaultPrompt() async {}
184+
181185
var customPromptTemplate: Binding<String> {
182186
.constant(UserPreferencesInfo.defaultPromptTemplate)
183187
}
188+
184189
@Published var availableModels: [LLMModelInfo] = [
185190
LLMModelInfo(name: "llama3.2", provider: "ollama"),
186191
LLMModelInfo(name: "codellama", provider: "ollama")

Recap/UseCases/Settings/SettingsView.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ struct SettingsView<GeneralViewModel: GeneralSettingsViewModelType>: View {
152152
}
153153

154154
// Just used for previews only!
155-
private final class PreviewGeneralSettingsViewModel: ObservableObject, GeneralSettingsViewModelType {
155+
private final class PreviewGeneralSettingsViewModel: GeneralSettingsViewModelType {
156156
var showAPIKeyAlert: Bool = false
157157

158158
var existingAPIKey: String? = nil
@@ -161,8 +161,6 @@ private final class PreviewGeneralSettingsViewModel: ObservableObject, GeneralSe
161161

162162
func dismissAPIKeyAlert() {}
163163

164-
var activeWarnings: [WarningItem] = []
165-
166164
@Published var availableModels: [LLMModelInfo] = [
167165
LLMModelInfo(name: "llama3.2", provider: "ollama"),
168166
LLMModelInfo(name: "codellama", provider: "ollama")

Recap/UseCases/Settings/ViewModels/General/GeneralSettingsViewModel.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,21 @@ final class GeneralSettingsViewModel: GeneralSettingsViewModelType {
177177
}
178178
}
179179

180+
func updateCustomPromptTemplate(_ template: String) async {
181+
customPromptTemplateValue = template
182+
183+
do {
184+
let templateToSave = template.isEmpty ? nil : template
185+
try await userPreferencesRepository.updateSummaryPromptTemplate(templateToSave)
186+
} catch {
187+
errorMessage = error.localizedDescription
188+
}
189+
}
190+
191+
func resetToDefaultPrompt() async {
192+
await updateCustomPromptTemplate(UserPreferencesInfo.defaultPromptTemplate)
193+
}
194+
180195
func toggleAutoStopRecording(_ enabled: Bool) async {
181196
errorMessage = nil
182197
isAutoStopRecording = enabled

Recap/UseCases/Settings/ViewModels/General/GeneralSettingsViewModelType.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ protocol GeneralSettingsViewModelType: ObservableObject {
2424
func selectProvider(_ provider: LLMProvider) async
2525
func toggleAutoDetectMeetings(_ enabled: Bool) async
2626
func toggleAutoStopRecording(_ enabled: Bool) async
27+
func updateCustomPromptTemplate(_ template: String) async
28+
func resetToDefaultPrompt() async
2729
func saveAPIKey(_ apiKey: String) async throws
2830
func dismissAPIKeyAlert()
29-
}
31+
}

0 commit comments

Comments
 (0)