Skip to content

Commit

Permalink
chore: Update settings based on feedback and PR review
Browse files Browse the repository at this point in the history
Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Oct 24, 2023
1 parent 2e51288 commit e19fe25
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 37 deletions.
24 changes: 6 additions & 18 deletions src/runtime/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,24 +472,14 @@ fn migrate_storage_schema_to_v9<E: Env>() -> 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))
Expand Down Expand Up @@ -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,
}
});
Expand Down
13 changes: 7 additions & 6 deletions src/types/profile/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateTime<Utc>>,
Expand Down Expand Up @@ -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,
}
Expand Down
6 changes: 3 additions & 3 deletions src/unit_tests/serde/default_tokens_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
20 changes: 10 additions & 10 deletions src/unit_tests/serde/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit e19fe25

Please sign in to comment.