format
This commit is contained in:
parent
3b3ed5abc5
commit
315c32eab4
7 changed files with 35 additions and 23 deletions
|
|
@ -73,7 +73,7 @@ pub async fn update_recording_retention_period(
|
|||
period: String,
|
||||
) -> Result<(), String> {
|
||||
use crate::settings::RecordingRetentionPeriod;
|
||||
|
||||
|
||||
let retention_period = match period.as_str() {
|
||||
"never" => RecordingRetentionPeriod::Never,
|
||||
"preserve_limit" => RecordingRetentionPeriod::PreserveLimit,
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ pub fn open_recordings_folder(app: AppHandle) -> Result<(), String> {
|
|||
.path()
|
||||
.app_data_dir()
|
||||
.map_err(|e| format!("Failed to get app data directory: {}", e))?;
|
||||
|
||||
|
||||
let recordings_dir = app_data_dir.join("recordings");
|
||||
|
||||
|
||||
let path = recordings_dir.to_string_lossy().as_ref().to_string();
|
||||
app.opener()
|
||||
.open_path(path, None::<String>)
|
||||
.map_err(|e| format!("Failed to open recordings folder: {}", e))?;
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,7 +229,10 @@ impl HistoryManager {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn cleanup_by_time(&self, retention_period: crate::settings::RecordingRetentionPeriod) -> Result<()> {
|
||||
fn cleanup_by_time(
|
||||
&self,
|
||||
retention_period: crate::settings::RecordingRetentionPeriod,
|
||||
) -> Result<()> {
|
||||
let conn = self.get_connection()?;
|
||||
|
||||
// Calculate cutoff timestamp (current time minus retention period)
|
||||
|
|
@ -243,7 +246,7 @@ impl HistoryManager {
|
|||
|
||||
// Get all unsaved entries older than the cutoff timestamp
|
||||
let mut stmt = conn.prepare(
|
||||
"SELECT id, file_name FROM transcription_history WHERE saved = 0 AND timestamp < ?1"
|
||||
"SELECT id, file_name FROM transcription_history WHERE saved = 0 AND timestamp < ?1",
|
||||
)?;
|
||||
|
||||
let rows = stmt.query_map(params![cutoff_timestamp], |row| {
|
||||
|
|
@ -258,7 +261,10 @@ impl HistoryManager {
|
|||
let deleted_count = self.delete_entries_and_files(&entries_to_delete)?;
|
||||
|
||||
if deleted_count > 0 {
|
||||
debug!("Cleaned up {} old history entries based on retention period", deleted_count);
|
||||
debug!(
|
||||
"Cleaned up {} old history entries based on retention period",
|
||||
deleted_count
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@ interface RecordingRetentionPeriodProps {
|
|||
grouped?: boolean;
|
||||
}
|
||||
|
||||
export const RecordingRetentionPeriodSelector: React.FC<RecordingRetentionPeriodProps> = React.memo(
|
||||
({ descriptionMode = "tooltip", grouped = false }) => {
|
||||
const {
|
||||
getSetting,
|
||||
updateSetting,
|
||||
isUpdating,
|
||||
} = useSettings();
|
||||
export const RecordingRetentionPeriodSelector: React.FC<RecordingRetentionPeriodProps> =
|
||||
React.memo(({ descriptionMode = "tooltip", grouped = false }) => {
|
||||
const { getSetting, updateSetting, isUpdating } = useSettings();
|
||||
|
||||
const selectedRetentionPeriod = getSetting("recording_retention_period") || "never";
|
||||
const selectedRetentionPeriod =
|
||||
getSetting("recording_retention_period") || "never";
|
||||
const historyLimit = getSetting("history_limit") || 5;
|
||||
|
||||
const handleRetentionPeriodSelect = async (period: string) => {
|
||||
await updateSetting("recording_retention_period", period as RecordingRetentionPeriod);
|
||||
await updateSetting(
|
||||
"recording_retention_period",
|
||||
period as RecordingRetentionPeriod,
|
||||
);
|
||||
};
|
||||
|
||||
const retentionOptions = [
|
||||
|
|
@ -48,7 +48,7 @@ export const RecordingRetentionPeriodSelector: React.FC<RecordingRetentionPeriod
|
|||
/>
|
||||
</SettingContainer>
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
RecordingRetentionPeriodSelector.displayName = "RecordingRetentionPeriodSelector";
|
||||
RecordingRetentionPeriodSelector.displayName =
|
||||
"RecordingRetentionPeriodSelector";
|
||||
|
|
|
|||
|
|
@ -24,4 +24,4 @@ export const AdvancedSettings: React.FC = () => {
|
|||
</SettingsGroup>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@ export const DebugSettings: React.FC = () => {
|
|||
/>
|
||||
<WordCorrectionThreshold descriptionMode="tooltip" grouped={true} />
|
||||
<HistoryLimit descriptionMode="tooltip" grouped={true} />
|
||||
<RecordingRetentionPeriodSelector descriptionMode="tooltip" grouped={true} />
|
||||
<RecordingRetentionPeriodSelector
|
||||
descriptionMode="tooltip"
|
||||
grouped={true}
|
||||
/>
|
||||
<AlwaysOnMicrophone descriptionMode="tooltip" grouped={true} />
|
||||
<ClamshellMicrophoneSelector descriptionMode="tooltip" grouped={true} />
|
||||
<PostProcessingToggle descriptionMode="tooltip" grouped={true} />
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ export const RecordingRetentionPeriodSchema = z.enum([
|
|||
"weeks2",
|
||||
"months3",
|
||||
]);
|
||||
export type RecordingRetentionPeriod = z.infer<typeof RecordingRetentionPeriodSchema>;
|
||||
export type RecordingRetentionPeriod = z.infer<
|
||||
typeof RecordingRetentionPeriodSchema
|
||||
>;
|
||||
|
||||
export const LLMPromptSchema = z.object({
|
||||
id: z.string(),
|
||||
|
|
@ -98,7 +100,8 @@ export const SettingsSchema = z.object({
|
|||
model_unload_timeout: ModelUnloadTimeoutSchema.optional().default("never"),
|
||||
word_correction_threshold: z.number().optional().default(0.18),
|
||||
history_limit: z.number().optional().default(5),
|
||||
recording_retention_period: RecordingRetentionPeriodSchema.optional().default("preserve_limit"),
|
||||
recording_retention_period:
|
||||
RecordingRetentionPeriodSchema.optional().default("preserve_limit"),
|
||||
paste_method: PasteMethodSchema.optional().default("ctrl_v"),
|
||||
clipboard_handling: ClipboardHandlingSchema.optional().default("dont_modify"),
|
||||
post_process_enabled: z.boolean().optional().default(false),
|
||||
|
|
|
|||
Loading…
Reference in a new issue