From e19fe25f8770cfd956773aaaebb913e5eb895abb Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Tue, 24 Oct 2023 15:42:06 +0300 Subject: [PATCH] chore: Update settings based on feedback and PR review Signed-off-by: Lachezar Lechev --- src/runtime/env.rs | 24 ++++++---------------- src/types/profile/settings.rs | 13 ++++++------ src/unit_tests/serde/default_tokens_ext.rs | 6 +++--- src/unit_tests/serde/settings.rs | 20 +++++++++--------- 4 files changed, 26 insertions(+), 37 deletions(-) diff --git a/src/runtime/env.rs b/src/runtime/env.rs index af950e7ce..a0e1c6779 100644 --- a/src/runtime/env.rs +++ b/src/runtime/env.rs @@ -472,24 +472,14 @@ fn migrate_storage_schema_to_v9() -> TryEnvFuture<()> { .and_then(|settings| settings.as_object_mut()) { Some(settings) => { - // override the seekTimeDuration with the new value - // and take the old value to put in the seekShiftTimeDuration - let old_seek_time_duration = settings - // new default is 20 seconds - .insert( - "seekTimeDuration".into(), - serde_json::Value::Number(20_000_u32.into()), - ); - - // move the old value to the new seek shift time + // short (i.e. finer) seeking time is 3 seconds settings.insert( - "seekShiftTimeDuration".to_owned(), - old_seek_time_duration - .unwrap_or(serde_json::Value::Number(10_000_u32.into())), + "seekShortTimeDuration".to_owned(), + serde_json::Value::Number(3_000_u32.into()), ); // add the new setting for Escape key exiting full screen - settings.insert("escExistsFullscreen".to_owned(), true.into()); + settings.insert("escExistFullscreen".to_owned(), true.into()); // add the new setting for pause on minimize, which is disabled by default settings.insert("pauseOnMinimize".to_owned(), false.into()); E::set_storage(PROFILE_STORAGE_KEY, Some(&profile)) @@ -838,15 +828,13 @@ mod test { let _test_env_guard = TestEnv::reset().expect("Should lock TestEnv"); let profile_before = json!({ "settings": { - "seekTimeDuration": 10000, } }); let migrated_profile = json!({ "settings": { - "escExistsFullscreen": true, - "seekTimeDuration": 20000, - "seekShiftTimeDuration": 10000, + "escExistFullscreen": true, + "seekShortTimeDuration": 3000, "pauseOnMinimize": false, } }); diff --git a/src/types/profile/settings.rs b/src/types/profile/settings.rs index 155563bfe..43b6779fa 100644 --- a/src/types/profile/settings.rs +++ b/src/types/profile/settings.rs @@ -27,11 +27,12 @@ pub struct Settings { pub subtitles_background_color: String, pub subtitles_outline_color: String, /// Whether or not the Escape key should exists from the app when in Full screen. - pub esc_exists_fullscreen: bool, + pub esc_exist_fullscreen: bool, /// The Seek time duration (in milliseconds) is when using the Arrow keys pub seek_time_duration: u32, - /// The Seek shift time duration (in milliseconds) is when using the Arrow keys + Shift - pub seek_shift_time_duration: u32, + /// The Seek short time duration (in milliseconds) is when we are finer seeking, + /// e.g. using the Arrow keys + Shift + pub seek_short_time_duration: u32, /// Whether we should pause the playback when the application get's minimized pub pause_on_minimize: bool, pub streaming_server_warning_dismissed: Option>, @@ -67,9 +68,9 @@ impl Default for Settings { subtitles_text_color: "#FFFFFFFF".to_owned(), subtitles_background_color: "#00000000".to_owned(), subtitles_outline_color: "#000000".to_owned(), - esc_exists_fullscreen: true, - seek_time_duration: 20000, - seek_shift_time_duration: 10000, + esc_exist_fullscreen: true, + seek_time_duration: 10000, + seek_short_time_duration: 3000, pause_on_minimize: false, streaming_server_warning_dismissed: None, } diff --git a/src/unit_tests/serde/default_tokens_ext.rs b/src/unit_tests/serde/default_tokens_ext.rs index 59d91aeea..5f5eb8969 100644 --- a/src/unit_tests/serde/default_tokens_ext.rs +++ b/src/unit_tests/serde/default_tokens_ext.rs @@ -416,12 +416,12 @@ impl DefaultTokens for Settings { Token::Str("#00000000"), Token::Str("subtitlesOutlineColor"), Token::Str("#000000"), - Token::Str("escExistsFullscreen"), + Token::Str("escExistFullscreen"), Token::Bool(true), Token::Str("seekTimeDuration"), - Token::U32(20000), - Token::Str("seekShiftTimeDuration"), Token::U32(10000), + Token::Str("seekShortTimeDuration"), + Token::U32(3000), Token::Str("pauseOnMinimize"), Token::Bool(false), Token::Str("streamingServerWarningDismissed"), diff --git a/src/unit_tests/serde/settings.rs b/src/unit_tests/serde/settings.rs index a9341961a..9491ba86e 100644 --- a/src/unit_tests/serde/settings.rs +++ b/src/unit_tests/serde/settings.rs @@ -27,9 +27,9 @@ fn settings() { subtitles_text_color: "subtitles_text_color".to_owned(), subtitles_background_color: "subtitles_background_color".to_owned(), subtitles_outline_color: "subtitles_outline_color".to_owned(), - esc_exists_fullscreen: true, - seek_time_duration: 1, - seek_shift_time_duration: 2, + esc_exist_fullscreen: true, + seek_time_duration: 10, + seek_short_time_duration: 3, pause_on_minimize: true, streaming_server_warning_dismissed: Some( Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap(), @@ -86,12 +86,12 @@ fn settings() { Token::Str("subtitles_background_color"), Token::Str("subtitlesOutlineColor"), Token::Str("subtitles_outline_color"), - Token::Str("escExistsFullscreen"), + Token::Str("escExistFullscreen"), Token::Bool(true), Token::Str("seekTimeDuration"), - Token::U32(1), - Token::Str("seekShiftTimeDuration"), - Token::U32(2), + Token::U32(10), + Token::Str("seekShortTimeDuration"), + Token::U32(3), Token::Str("pauseOnMinimize"), Token::Bool(true), Token::Str("streamingServerWarningDismissed"), @@ -150,12 +150,12 @@ fn settings_de() { Token::Str("#00000000"), Token::Str("subtitlesOutlineColor"), Token::Str("#000000"), - Token::Str("escExistsFullscreen"), + Token::Str("escExistFullscreen"), Token::Bool(true), Token::Str("seekTimeDuration"), - Token::U32(20000), - Token::Str("seekShiftTimeDuration"), Token::U32(10000), + Token::Str("seekShortTimeDuration"), + Token::U32(3000), Token::Str("pauseOnMinimize"), Token::Bool(false), Token::Str("streamingServerWarningDismissed"),