improvements to the sleep timer
This commit is contained in:
@@ -1231,11 +1231,24 @@ pub async fn player_get_audio_settings(
|
||||
#[tauri::command]
|
||||
pub async fn player_set_video_settings(
|
||||
video_settings: State<'_, VideoSettingsWrapper>,
|
||||
player: State<'_, PlayerStateWrapper>,
|
||||
settings: VideoSettings,
|
||||
) -> Result<VideoSettings, String> {
|
||||
let mut current = video_settings.0.lock().map_err(|e| e.to_string())?;
|
||||
*current = settings.with_countdown_clamped();
|
||||
Ok(current.clone())
|
||||
let validated = settings.with_countdown_clamped();
|
||||
{
|
||||
let mut current = video_settings.0.lock().map_err(|e| e.to_string())?;
|
||||
*current = validated.clone();
|
||||
} // Drop MutexGuard before await
|
||||
|
||||
// Sync to PlayerController's autoplay settings so on_playback_ended() uses current values
|
||||
let controller = player.0.lock().await;
|
||||
controller.set_autoplay_settings(AutoplaySettings {
|
||||
enabled: validated.auto_play_next_episode,
|
||||
countdown_seconds: validated.auto_play_countdown_seconds,
|
||||
max_episodes: validated.auto_play_max_episodes,
|
||||
});
|
||||
|
||||
Ok(validated)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -2333,16 +2346,18 @@ pub async fn player_set_autoplay_settings(
|
||||
};
|
||||
|
||||
let query = Query::with_params(
|
||||
"INSERT INTO user_player_settings (user_id, autoplay_next_episode, autoplay_countdown_seconds, updated_at)
|
||||
VALUES (?, ?, ?, CURRENT_TIMESTAMP)
|
||||
"INSERT INTO user_player_settings (user_id, autoplay_next_episode, autoplay_countdown_seconds, autoplay_max_episodes, updated_at)
|
||||
VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)
|
||||
ON CONFLICT(user_id) DO UPDATE SET
|
||||
autoplay_next_episode = excluded.autoplay_next_episode,
|
||||
autoplay_countdown_seconds = excluded.autoplay_countdown_seconds,
|
||||
autoplay_max_episodes = excluded.autoplay_max_episodes,
|
||||
updated_at = CURRENT_TIMESTAMP",
|
||||
vec![
|
||||
QueryParam::String(user_id),
|
||||
QueryParam::Int(if validated.enabled { 1 } else { 0 }),
|
||||
QueryParam::Int(validated.countdown_seconds as i32),
|
||||
QueryParam::Int(validated.max_episodes as i32),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user