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 QuickCommitModal from '$lib/components/QuickCommitModal.svelte';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { unsubscribe } from '$lib/utils';
|
import { unsubscribe } from '$lib/utils';
|
||||||
import { format } from 'date-fns';
|
|
||||||
import { PUBLIC_API_BASE_URL } from '$env/static/public';
|
import { PUBLIC_API_BASE_URL } from '$env/static/public';
|
||||||
import { events, hotkeys } from '$lib';
|
import { events, hotkeys } from '$lib';
|
||||||
|
|
||||||
@ -35,7 +34,7 @@
|
|||||||
hotkeys.on('Meta+P', () => goto(`/projects/${$project.id}/`)),
|
hotkeys.on('Meta+P', () => goto(`/projects/${$project.id}/`)),
|
||||||
hotkeys.on('Meta+Shift+,', () => goto(`/projects/${$project.id}/settings/`)),
|
hotkeys.on('Meta+Shift+,', () => goto(`/projects/${$project.id}/settings/`)),
|
||||||
hotkeys.on('Meta+R', () =>
|
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/`))
|
hotkeys.on('a i p', () => goto(`/projects/${$project.id}/aiplayground/`))
|
||||||
)
|
)
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
import { redirect } from '@sveltejs/kit';
|
import { error, redirect } from '@sveltejs/kit';
|
||||||
import { format } from 'date-fns';
|
import { format, compareDesc } from 'date-fns';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
import { wrapLoadWithSentry } from '@sentry/sveltekit';
|
import { wrapLoadWithSentry } from '@sentry/sveltekit';
|
||||||
|
|
||||||
export const load: PageLoad = wrapLoadWithSentry(async ({ parent, url }) => {
|
export const load: PageLoad = wrapLoadWithSentry(async ({ parent, url }) => {
|
||||||
const { sessions, projectId } = await parent();
|
const { sessions, projectId } = await parent();
|
||||||
const date = format(new Date(), 'yyyy-MM-dd');
|
const latestDate = await sessions.load().then((sessions) =>
|
||||||
const dateSessions = await sessions
|
sessions
|
||||||
.load()
|
.map((session) => session.meta.startTimestampMs)
|
||||||
.then((sessions) =>
|
.sort(compareDesc)
|
||||||
sessions.filter((session) => format(session.meta.startTimestampMs, 'yyyy-MM-dd') === date)
|
.shift()
|
||||||
);
|
);
|
||||||
const firstSession = dateSessions[dateSessions.length - 1];
|
if (!latestDate) throw error(404, 'No sessions found');
|
||||||
throw redirect(302, `/projects/${projectId}/player/${date}/${firstSession.id}${url.search}`);
|
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 { format } from 'date-fns';
|
||||||
import { get } from '@square/svelte-store';
|
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
import { wrapLoadWithSentry } from '@sentry/sveltekit';
|
import { wrapLoadWithSentry } from '@sentry/sveltekit';
|
||||||
|
|
||||||
export const load: PageLoad = wrapLoadWithSentry(async ({ parent, params, url }) => {
|
export const load: PageLoad = wrapLoadWithSentry(async ({ parent, params, url }) => {
|
||||||
const { sessions, projectId } = await parent();
|
const { sessions, projectId } = await parent();
|
||||||
await sessions.load();
|
const dateSessions = await sessions
|
||||||
const dateSessions = get(sessions).filter(
|
.load()
|
||||||
(session) => format(session.meta.startTimestampMs, 'yyyy-MM-dd') === params.date
|
.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];
|
const firstSession = dateSessions[dateSessions.length - 1];
|
||||||
throw redirect(
|
throw redirect(
|
||||||
302,
|
302,
|
||||||
|
Loading…
Reference in New Issue
Block a user