mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-23 17:43:47 +03:00
fix cmd+r redirects
This commit is contained in:
parent
f04505d8e7
commit
90f475d7e5
@ -8,7 +8,6 @@
|
||||
import QuickCommitModal from '$lib/components/QuickCommitModal.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { unsubscribe } from '$lib/utils';
|
||||
import { format } from 'date-fns';
|
||||
import { PUBLIC_API_BASE_URL } from '$env/static/public';
|
||||
import { events, hotkeys } from '$lib';
|
||||
|
||||
@ -35,7 +34,7 @@
|
||||
hotkeys.on('Meta+P', () => goto(`/projects/${$project.id}/`)),
|
||||
hotkeys.on('Meta+Shift+,', () => goto(`/projects/${$project.id}/settings/`)),
|
||||
hotkeys.on('Meta+R', () =>
|
||||
goto(`/projects/${$project.id}/player/${format(new Date(), 'yyyy-MM-dd')}`)
|
||||
goto(`/projects/${$project.id}/player/`)
|
||||
),
|
||||
hotkeys.on('a i p', () => goto(`/projects/${$project.id}/aiplayground/`))
|
||||
)
|
||||
|
@ -1,16 +1,19 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { format } from 'date-fns';
|
||||
import { error, redirect } from '@sveltejs/kit';
|
||||
import { format, compareDesc } from 'date-fns';
|
||||
import type { PageLoad } from './$types';
|
||||
import { wrapLoadWithSentry } from '@sentry/sveltekit';
|
||||
|
||||
export const load: PageLoad = wrapLoadWithSentry(async ({ parent, url }) => {
|
||||
const { sessions, projectId } = await parent();
|
||||
const date = format(new Date(), 'yyyy-MM-dd');
|
||||
const dateSessions = await sessions
|
||||
.load()
|
||||
.then((sessions) =>
|
||||
sessions.filter((session) => format(session.meta.startTimestampMs, 'yyyy-MM-dd') === date)
|
||||
);
|
||||
const firstSession = dateSessions[dateSessions.length - 1];
|
||||
throw redirect(302, `/projects/${projectId}/player/${date}/${firstSession.id}${url.search}`);
|
||||
const latestDate = await sessions.load().then((sessions) =>
|
||||
sessions
|
||||
.map((session) => session.meta.startTimestampMs)
|
||||
.sort(compareDesc)
|
||||
.shift()
|
||||
);
|
||||
if (!latestDate) throw error(404, 'No sessions found');
|
||||
throw redirect(
|
||||
302,
|
||||
`/projects/${projectId}/player/${format(latestDate, 'yyyy-MM-dd')}/${url.search}`
|
||||
);
|
||||
});
|
||||
|
@ -1,15 +1,18 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { redirect, error } from '@sveltejs/kit';
|
||||
import { format } from 'date-fns';
|
||||
import { get } from '@square/svelte-store';
|
||||
import type { PageLoad } from './$types';
|
||||
import { wrapLoadWithSentry } from '@sentry/sveltekit';
|
||||
|
||||
export const load: PageLoad = wrapLoadWithSentry(async ({ parent, params, url }) => {
|
||||
const { sessions, projectId } = await parent();
|
||||
await sessions.load();
|
||||
const dateSessions = get(sessions).filter(
|
||||
(session) => format(session.meta.startTimestampMs, 'yyyy-MM-dd') === params.date
|
||||
);
|
||||
const dateSessions = await sessions
|
||||
.load()
|
||||
.then((sessions) =>
|
||||
sessions.filter(
|
||||
(session) => format(session.meta.startTimestampMs, 'yyyy-MM-dd') === params.date
|
||||
)
|
||||
);
|
||||
if (!dateSessions.length) throw error(404, 'No sessions found');
|
||||
const firstSession = dateSessions[dateSessions.length - 1];
|
||||
throw redirect(
|
||||
302,
|
||||
|
Loading…
Reference in New Issue
Block a user