Skip to content

Commit

Permalink
Merge branch 'main' into youtube-music-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Jan 2, 2025
2 parents d189a4f + 1161083 commit 2bf7563
Show file tree
Hide file tree
Showing 19 changed files with 1,234 additions and 675 deletions.
1 change: 0 additions & 1 deletion apps/frontend/app/lib/generals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ export const getMetadataDetailsQuery = (metadataId?: string | null) =>
.request(MetadataDetailsDocument, { metadataId })
.then((data) => data.metadataDetails)
: skipToken,
staleTime: dayjs.duration(1, "day").asMilliseconds(),
});

export const getUserMetadataDetailsQuery = (metadataId?: string | null) =>
Expand Down
13 changes: 11 additions & 2 deletions apps/frontend/app/lib/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ import {
getUserMetadataDetailsQuery,
selectRandomElement,
} from "~/lib/generals";
import { type InProgressWorkout, useCurrentWorkout } from "~/lib/state/fitness";
import {
type InProgressWorkout,
useCurrentWorkout,
useCurrentWorkoutStopwatchAtom,
useCurrentWorkoutTimerAtom,
} from "~/lib/state/fitness";
import type { loader as dashboardLoader } from "~/routes/_dashboard";

export const useGetMantineColors = () => {
Expand Down Expand Up @@ -96,9 +101,13 @@ export const useConfirmSubmit = () => {

export const useGetWorkoutStarter = () => {
const revalidator = useRevalidator();
const [_, setCurrentWorkout] = useCurrentWorkout();
const [_w, setCurrentWorkout] = useCurrentWorkout();
const [_t, setTimer] = useCurrentWorkoutTimerAtom();
const [_s, setStopwatch] = useCurrentWorkoutStopwatchAtom();

const fn = (wkt: InProgressWorkout, action: FitnessAction) => {
setTimer(null);
setStopwatch(null);
setCurrentWorkout(wkt);
window.location.href = $path("/fitness/:action", { action });
revalidator.revalidate();
Expand Down
21 changes: 15 additions & 6 deletions apps/frontend/app/lib/state/fitness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ type AlreadyDoneExerciseSet = Pick<ExerciseSet, "statistic">;
type Media = { imageSrc: string; key: string };

export type Exercise = {
name: string;
lot: ExerciseLot;
identifier: string;
exerciseId: string;
Expand Down Expand Up @@ -87,6 +86,7 @@ export type InProgressWorkout = {
replacingExerciseIdx?: number;
updateWorkoutTemplateId?: string;
durations: Array<WorkoutDuration>;
timerDrawerLot: "timer" | "stopwatch";
currentActionOrCompleted: FitnessAction;
};

Expand Down Expand Up @@ -118,6 +118,7 @@ export const getDefaultWorkout = (
videos: [],
supersets: [],
exercises: [],
timerDrawerLot: "timer",
startTime: date.toISOString(),
currentActionOrCompleted: fitnessEntity,
durations: [{ from: date.toISOString() }],
Expand All @@ -132,7 +133,6 @@ export const getExerciseDetailsQuery = (exerciseId: string) =>
clientGqlService
.request(ExerciseDetailsDocument, { exerciseId })
.then((data) => data.exerciseDetails),
staleTime: dayjsLib.duration(1, "day").asMilliseconds(),
});

export const getUserExerciseDetailsQuery = (exerciseId: string) =>
Expand Down Expand Up @@ -262,12 +262,23 @@ export type CurrentWorkoutTimer = {
triggeredBy?: { exerciseIdentifier: string; setIdx: number };
};

const timerAtom = atomWithStorage<CurrentWorkoutTimer | null>(
const currentWorkoutTimerAtom = atomWithStorage<CurrentWorkoutTimer | null>(
"CurrentWorkoutTimer",
null,
);

export const useTimerAtom = () => useAtom(timerAtom);
export const useCurrentWorkoutTimerAtom = () =>
useAtom(currentWorkoutTimerAtom);

export type CurrentWorkoutStopwatch = Array<WorkoutDuration> | null;

const currentWorkoutStopwatchAtom = atomWithStorage<CurrentWorkoutStopwatch>(
"CurrentWorkoutStopwatch",
null,
);

export const useCurrentWorkoutStopwatchAtom = () =>
useAtom(currentWorkoutStopwatchAtom);

const measurementsDrawerOpenAtom = atom(false);

Expand Down Expand Up @@ -308,7 +319,6 @@ export const duplicateOldWorkout = async (
const exerciseDetails = await getExerciseDetails(ex.id);
inProgress.exercises.push({
identifier: randomUUID(),
name: exerciseDetails.details.name,
isShowDetailsOpen: userFitnessPreferences.logging.showDetailsWhileEditing
? exerciseIdx === 0
: false,
Expand Down Expand Up @@ -397,7 +407,6 @@ export const addExerciseToWorkout = async (
}
draft.exercises.push({
identifier: randomUUID(),
name: exerciseDetails.details.name,
isShowDetailsOpen: userFitnessPreferences.logging.showDetailsWhileEditing,
exerciseId: ex.name,
lot: ex.lot,
Expand Down
2 changes: 0 additions & 2 deletions apps/frontend/app/routes/_dashboard.collections.list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ import {
PRO_REQUIRED_MESSAGE,
clientGqlService,
commaDelimitedString,
dayjsLib,
getPartialMetadataDetailsQuery,
openConfirmationModal,
queryClient,
Expand Down Expand Up @@ -309,7 +308,6 @@ const DisplayCollection = (props: {
}
return images;
},
staleTime: dayjsLib.duration(1, "hour").asMilliseconds(),
});

const [hoveredStates, setHoveredStates] = useListState<boolean>([]);
Expand Down
Loading

0 comments on commit 2bf7563

Please sign in to comment.