mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-29 12:33:49 +03:00
Fix session navigation ordering
- Order sessions by start timestamp - Update derived states to use ordered sessions state [src/routes/projects/[projectId]/sessions/[sessionId]/+page.ts] - Add a derived state to order the sessions by start timestamp - Update the `session` derived state to use the new ordered sessions state - Update the `previousSession` and `nextSession` derived states to use the new ordered sessions state
This commit is contained in:
parent
a0b6e82795
commit
624796ba97
@ -18,14 +18,18 @@ export const load: PageLoad = async ({ parent, params }) => {
|
||||
projectId: params.projectId,
|
||||
sessionId: params.sessionId,
|
||||
});
|
||||
const orderedSessions = derived(sessions, (sessions) =>{
|
||||
return sessions.slice().sort((a, b) => a.meta.startTs - b.meta.startTs);
|
||||
});
|
||||
return {
|
||||
session: derived(sessions, (sessions) => {
|
||||
orderedSessions,
|
||||
session: derived(orderedSessions, (sessions) => {
|
||||
const result = sessions.find(
|
||||
(session) => session.id === params.sessionId
|
||||
);
|
||||
return result ? result : sessions[0];
|
||||
}),
|
||||
previousSesssion: derived(sessions, (sessions) => {
|
||||
previousSesssion: derived(orderedSessions, (sessions) => {
|
||||
const currentSessionIndex = sessions.findIndex(
|
||||
(session) => session.id === params.sessionId
|
||||
);
|
||||
@ -35,7 +39,7 @@ export const load: PageLoad = async ({ parent, params }) => {
|
||||
return undefined;
|
||||
}
|
||||
}),
|
||||
nextSession: derived(sessions, (sessions) => {
|
||||
nextSession: derived(orderedSessions, (sessions) => {
|
||||
const currentSessionIndex = sessions.findIndex(
|
||||
(session) => session.id === params.sessionId
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user