Repository: IgnisDa/ryot (language: rust)

Issue:
Ignore Season 0 when using "Mark all unseen episodes before this as seen"
To reproduce: 
1. Click "Mark as seen" in any season > 0
2. Tick "Mark all unseen episodes before this as seen"
3. Observe that all Specials (Season 0) are also marked as seen

As you said in other issues yourself, people don't typically watch these specials, so I would like to ignore them


Discussion / hints:

Fix patch:
diff --git a/apps/frontend/app/routes/_dashboard.fitness.$action.tsx b/apps/frontend/app/routes/_dashboard.fitness.$action.tsx
index 77765fa87a..d3cd6903d3 100644
--- a/apps/frontend/app/routes/_dashboard.fitness.$action.tsx
+++ b/apps/frontend/app/routes/_dashboard.fitness.$action.tsx
@@ -322,7 +322,11 @@ export default function Page() {
 					const exerciseIdx = currentWorkout?.exercises.findIndex(
 						(c) => c.identifier === triggeredBy.exerciseIdentifier,
 					);
-					if (exerciseIdx !== undefined && exerciseIdx !== -1) {
+					if (
+						exerciseIdx !== -1 &&
+						exerciseIdx !== undefined &&
+						userPreferences.fitness.logging.promptForRestTimer
+					) {
 						performTasksAfterSetConfirmed(triggeredBy.setIdx, exerciseIdx);
 					}
 				}
diff --git a/apps/frontend/app/routes/_dashboard.settings.preferences.tsx b/apps/frontend/app/routes/_dashboard.settings.preferences.tsx
index 292a153967..c41a19d34a 100644
--- a/apps/frontend/app/routes/_dashboard.settings.preferences.tsx
+++ b/apps/frontend/app/routes/_dashboard.settings.preferences.tsx
@@ -490,7 +490,7 @@ export default function Page() {
 										<IconBellRinging />
 									</ActionIcon>
 									<Text size="xs">
-										Show me notifications related to the current workout
+										Send me notifications related to the current workout
 									</Text>
 								</Group>
 								<Select
@@ -544,6 +544,7 @@ export default function Page() {
 								</SimpleGrid>
 							</Input.Wrapper>
 							<Divider />
+							<Title order={4}>Current workout</Title>
 							{(
 								[
 									"muteSounds",
diff --git a/apps/frontend/app/routes/actions.tsx b/apps/frontend/app/routes/actions.tsx
index bbe3b743ac..8349ed7718 100644
--- a/apps/frontend/app/routes/actions.tsx
+++ b/apps/frontend/app/routes/actions.tsx
@@ -351,6 +351,7 @@ export const action = async ({ request }: ActionFunctionArgs) => {
 						e.seasonNumber === submission.showSeasonNumber &&
 						e.episodeNumber === submission.showEpisodeNumber,
 				);
+				const selectedEpisode = allEpisodesInShow[selectedEpisodeIndex];
 				const firstEpisodeOfShow = allEpisodesInShow[0];
 				const lastSeenEpisode = latestHistoryItem?.showExtraInformation || {
 					episode: firstEpisodeOfShow.episodeNumber,
@@ -365,11 +366,17 @@ export const action = async ({ request }: ActionFunctionArgs) => {
 					lastSeenEpisodeIndex + (latestHistoryItem ? 1 : 0);
 				if (selectedEpisodeIndex > firstEpisodeIndexToMark) {
 					for (let i = firstEpisodeIndexToMark; i < selectedEpisodeIndex; i++) {
-						const episode = allEpisodesInShow[i];
+						const currentEpisode = allEpisodesInShow[i];
+						if (
+							currentEpisode.seasonNumber === 0 &&
+							selectedEpisode.seasonNumber !== 0
+						) {
+							continue;
+						}
 						updates.push({
 							...variables,
-							showSeasonNumber: episode.seasonNumber,
-							showEpisodeNumber: episode.episodeNumber,
+							showSeasonNumber: currentEpisode.seasonNumber,
+							showEpisodeNumber: currentEpisode.episodeNumber,
 						});
 					}
 				}
diff --git a/crates/utils/dependent/src/lib.rs b/crates/utils/dependent/src/lib.rs
index cd15a84c71..21ad065daa 100644
--- a/crates/utils/dependent/src/lib.rs
+++ b/crates/utils/dependent/src/lib.rs
@@ -1697,7 +1697,7 @@ pub async fn create_or_update_user_workout(
     ss: &Arc<SupportingService>,
 ) -> Result<String> {
     let end_time = input.end_time;
-    let (duration, durations) = match input.durations.clone() {
+    let (mut duration, mut durations) = match input.durations.clone() {
         Some(durations) => {
             if durations.is_empty() {
                 return Err(Error::new("Durations cannot be empty"));
@@ -1729,11 +1729,15 @@ pub async fn create_or_update_user_workout(
     };
     let mut input = input;
     let (new_workout_id, to_update_workout) = match &input.update_workout_id {
-        Some(id) => (
-            id.to_owned(),
+        Some(id) => {
             // DEV: Unwrap to make sure we error out early if the workout to edit does not exist
-            Some(Workout::find_by_id(id).one(&ss.db).await?.unwrap()),
-        ),
+            let model = Workout::find_by_id(id).one(&ss.db).await?.unwrap();
+            duration = model.duration.try_into().unwrap();
+            if let Some(d) = model.information.durations.clone() {
+                durations = d;
+            }
+            (id.to_owned(), Some(model))
+        }
         None => (
             input
                 .create_workout_id
@@ -1960,6 +1964,13 @@ pub async fn create_or_update_user_workout(
         template_id: input.template_id,
         repeated_from: input.repeated_from,
         duration: duration.try_into().unwrap(),
+        information: WorkoutInformation {
+            assets: input.assets,
+            comment: input.comment,
+            supersets: input.supersets,
+            durations: Some(durations),
+            exercises: processed_exercises,
+        },
         summary: WorkoutSummary {
             focused,
             total: Some(summary_total),
@@ -1974,13 +1985,6 @@ pub async fn create_or_update_user_workout(
                 })
                 .collect(),
         },
-        information: WorkoutInformation {
-            assets: input.assets,
-            comment: input.comment,
-            supersets: input.supersets,
-            durations: Some(durations),
-            exercises: processed_exercises,
-        },
     };
     let mut insert: workout::ActiveModel = model.into();
     if let Some(old_workout) = to_update_workout.clone() {


Test patch: