mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-25 02:26:14 +03:00
use correct bookmark timestamp when creating
This commit is contained in:
parent
490f3ba657
commit
f08fa0133b
@ -1,5 +1,5 @@
|
|||||||
import { type Project, git } from '$lib/api';
|
import { type Project, git } from '$lib/api';
|
||||||
import { events, stores } from '$lib';
|
import { events } from '$lib';
|
||||||
import {
|
import {
|
||||||
IconGitCommit,
|
IconGitCommit,
|
||||||
IconFile,
|
IconFile,
|
||||||
@ -13,6 +13,8 @@ import {
|
|||||||
IconBookmark
|
IconBookmark
|
||||||
} from '$lib/icons';
|
} from '$lib/icons';
|
||||||
import type { SvelteComponent } from 'svelte';
|
import type { SvelteComponent } from 'svelte';
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
import { get } from '@square/svelte-store';
|
||||||
|
|
||||||
type ActionLink = {
|
type ActionLink = {
|
||||||
href: string;
|
href: string;
|
||||||
@ -80,6 +82,22 @@ const projectsGroup = ({ projects, input }: { projects: Project[]; input: string
|
|||||||
const commandsGroup = ({ project, input }: { project?: Project; input: string }): Group => ({
|
const commandsGroup = ({ project, input }: { project?: Project; input: string }): Group => ({
|
||||||
title: 'Commands',
|
title: 'Commands',
|
||||||
commands: [
|
commands: [
|
||||||
|
...(project && get(page).params.date
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
title: 'Bookmark',
|
||||||
|
hotkey: 'Meta+Shift+D',
|
||||||
|
action: () => events.emit('openBookmarkModal'),
|
||||||
|
icon: IconBookmark
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Quick Bookmark',
|
||||||
|
hotkey: 'D',
|
||||||
|
action: () => events.emit('createBookmark', { projectId: project.id }),
|
||||||
|
icon: IconBookmark
|
||||||
|
}
|
||||||
|
]
|
||||||
|
: []),
|
||||||
...(project
|
...(project
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
@ -96,18 +114,6 @@ const commandsGroup = ({ project, input }: { project?: Project; input: string })
|
|||||||
},
|
},
|
||||||
icon: IconRewind
|
icon: IconRewind
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: 'Quick Bookmark',
|
|
||||||
hotkey: 'D',
|
|
||||||
action: () => stores.bookmarks({ projectId: project.id }).create(),
|
|
||||||
icon: IconBookmark
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Bookmark',
|
|
||||||
hotkey: 'Meta+Shift+D',
|
|
||||||
action: () => events.emit('openBookmarkModal'),
|
|
||||||
icon: IconBookmark
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: 'Project settings',
|
title: 'Project settings',
|
||||||
hotkey: 'Meta+Shift+,',
|
hotkey: 'Meta+Shift+,',
|
||||||
|
@ -8,6 +8,7 @@ type Events = {
|
|||||||
openQuickCommitModal: () => void;
|
openQuickCommitModal: () => void;
|
||||||
openSendIssueModal: () => void;
|
openSendIssueModal: () => void;
|
||||||
openBookmarkModal: () => void;
|
openBookmarkModal: () => void;
|
||||||
|
createBookmark: (params: { projectId: string }) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const events = createNanoEvents<Events>();
|
const events = createNanoEvents<Events>();
|
||||||
|
@ -21,7 +21,6 @@ export default (params: { projectId: string }): Store => {
|
|||||||
if (!oldBookmark) return true;
|
if (!oldBookmark) return true;
|
||||||
return oldBookmark !== bookmark;
|
return oldBookmark !== bookmark;
|
||||||
});
|
});
|
||||||
console.log('changedBookmarks', changedBookmarks);
|
|
||||||
await Promise.all(changedBookmarks.map((bookmark) => bookmarks.upsert(bookmark)));
|
await Promise.all(changedBookmarks.map((bookmark) => bookmarks.upsert(bookmark)));
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
import { unsubscribe } from '$lib/utils';
|
import { unsubscribe } from '$lib/utils';
|
||||||
import { PUBLIC_API_BASE_URL } from '$env/static/public';
|
import { PUBLIC_API_BASE_URL } from '$env/static/public';
|
||||||
import { events, hotkeys, stores } from '$lib';
|
import { events, hotkeys, stores } from '$lib';
|
||||||
import BookmarkModal from './BookmarkModal.svelte';
|
|
||||||
import { bookmarks } from '$lib/stores';
|
|
||||||
|
|
||||||
export let data: LayoutData;
|
export let data: LayoutData;
|
||||||
const { cloud, project, head, statuses, diffs } = data;
|
const { cloud, project, head, statuses, diffs } = data;
|
||||||
@ -28,14 +26,10 @@
|
|||||||
$: selection = $page?.route?.id?.split('/')?.[3];
|
$: selection = $page?.route?.id?.split('/')?.[3];
|
||||||
|
|
||||||
let quickCommitModal: QuickCommitModal;
|
let quickCommitModal: QuickCommitModal;
|
||||||
let bookmarkModal: BookmarkModal;
|
|
||||||
onMount(() =>
|
onMount(() =>
|
||||||
unsubscribe(
|
unsubscribe(
|
||||||
events.on('openQuickCommitModal', () => quickCommitModal?.show()),
|
events.on('openQuickCommitModal', () => quickCommitModal?.show()),
|
||||||
events.on('openBookmarkModal', () => bookmarkModal?.show()),
|
|
||||||
|
|
||||||
hotkeys.on('D', () => bookmarks({ projectId: $project.id }).create()),
|
|
||||||
hotkeys.on('Meta+Shift+D', () => bookmarkModal?.show()),
|
|
||||||
hotkeys.on('C', () => events.emit('openQuickCommitModal')),
|
hotkeys.on('C', () => events.emit('openQuickCommitModal')),
|
||||||
hotkeys.on('Meta+Shift+C', () => goto(`/projects/${$project.id}/commit/`)),
|
hotkeys.on('Meta+Shift+C', () => goto(`/projects/${$project.id}/commit/`)),
|
||||||
hotkeys.on('Meta+T', () => goto(`/projects/${$project.id}/terminal/`)),
|
hotkeys.on('Meta+T', () => goto(`/projects/${$project.id}/terminal/`)),
|
||||||
@ -165,7 +159,3 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/await}
|
{/await}
|
||||||
|
|
||||||
{#await project.load() then}
|
|
||||||
<BookmarkModal bind:this={bookmarkModal} projectId={$project.id} />
|
|
||||||
{/await}
|
|
||||||
|
@ -23,11 +23,14 @@
|
|||||||
import { asyncDerived, derived } from '@square/svelte-store';
|
import { asyncDerived, derived } from '@square/svelte-store';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
import { events, hotkeys, stores, toasts } from '$lib';
|
||||||
|
import BookmarkModal from './BookmarkModal.svelte';
|
||||||
import tinykeys from 'tinykeys';
|
import tinykeys from 'tinykeys';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
import { unsubscribe } from '$lib/utils';
|
||||||
|
|
||||||
export let data: LayoutData;
|
export let data: LayoutData;
|
||||||
const { currentFilepath } = data;
|
const { currentFilepath, currentTimestamp } = data;
|
||||||
|
|
||||||
const unique = (value: any, index: number, self: any[]) => self.indexOf(value) === index;
|
const unique = (value: any, index: number, self: any[]) => self.indexOf(value) === index;
|
||||||
const lexically = (a: string, b: string) => a.localeCompare(b);
|
const lexically = (a: string, b: string) => a.localeCompare(b);
|
||||||
@ -116,7 +119,10 @@
|
|||||||
$page.params.date
|
$page.params.date
|
||||||
}/${sessionId}?${removeFromSearchParams($page.url.searchParams, 'delta').toString()}`;
|
}/${sessionId}?${removeFromSearchParams($page.url.searchParams, 'delta').toString()}`;
|
||||||
|
|
||||||
|
let bookmarkModal: BookmarkModal;
|
||||||
|
|
||||||
onMount(() =>
|
onMount(() =>
|
||||||
|
unsubscribe(
|
||||||
tinykeys(window, {
|
tinykeys(window, {
|
||||||
'Shift+ArrowRight': () =>
|
'Shift+ArrowRight': () =>
|
||||||
nextSessionId.load().then((sessionId) => {
|
nextSessionId.load().then((sessionId) => {
|
||||||
@ -126,7 +132,17 @@
|
|||||||
prevSessionId.load().then((sessionId) => {
|
prevSessionId.load().then((sessionId) => {
|
||||||
if (sessionId) goto(getSessionURI(sessionId));
|
if (sessionId) goto(getSessionURI(sessionId));
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
|
|
||||||
|
events.on('openBookmarkModal', () => bookmarkModal?.show($currentTimestamp)),
|
||||||
|
hotkeys.on('Meta+Shift+D', () => bookmarkModal?.show($currentTimestamp)),
|
||||||
|
hotkeys.on('D', () =>
|
||||||
|
stores
|
||||||
|
.bookmarks({ projectId: $projectId })
|
||||||
|
.create({ timestampMs: $currentTimestamp })
|
||||||
|
.then(() => toasts.success('Bookmark created'))
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -240,3 +256,5 @@
|
|||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<BookmarkModal bind:this={bookmarkModal} projectId={$projectId} />
|
||||||
|
@ -3,5 +3,6 @@ import type { LayoutLoad } from './$types';
|
|||||||
|
|
||||||
export const load: LayoutLoad = () => ({
|
export const load: LayoutLoad = () => ({
|
||||||
currentFilepath: writable(''),
|
currentFilepath: writable(''),
|
||||||
currentSessionId: writable('')
|
currentSessionId: writable(''),
|
||||||
|
currentTimestamp: writable(-1)
|
||||||
});
|
});
|
||||||
|
@ -8,13 +8,16 @@
|
|||||||
const bookmarks = stores.bookmarks({ projectId });
|
const bookmarks = stores.bookmarks({ projectId });
|
||||||
|
|
||||||
let isCreating = false;
|
let isCreating = false;
|
||||||
|
let timestampMs: number | undefined;
|
||||||
|
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
note = '';
|
note = '';
|
||||||
|
timestampMs = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const show = () => {
|
export const show = (ts: number) => {
|
||||||
reset();
|
reset();
|
||||||
|
timestampMs = ts;
|
||||||
modal.show();
|
modal.show();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -24,7 +27,7 @@
|
|||||||
const createBookmark = () =>
|
const createBookmark = () =>
|
||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
.then(() => (isCreating = true))
|
.then(() => (isCreating = true))
|
||||||
.then(() => bookmarks.create({ note }))
|
.then(() => bookmarks.create({ note, timestampMs }))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
toasts.success('Bookmark created');
|
toasts.success('Bookmark created');
|
||||||
modal.close();
|
modal.close();
|
@ -30,10 +30,11 @@
|
|||||||
import { asyncDerived, derived, writable } from '@square/svelte-store';
|
import { asyncDerived, derived, writable } from '@square/svelte-store';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import tinykeys from 'tinykeys';
|
import { unsubscribe } from '$lib/utils';
|
||||||
|
import { hotkeys } from '$lib';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
const { currentFilepath } = data;
|
const { currentFilepath, currentTimestamp } = data;
|
||||||
|
|
||||||
let fullContext = true;
|
let fullContext = true;
|
||||||
let context = 8;
|
let context = 8;
|
||||||
@ -112,6 +113,14 @@
|
|||||||
});
|
});
|
||||||
frame.subscribe((frame) => frame?.filepath && currentFilepath.set(frame.filepath));
|
frame.subscribe((frame) => frame?.filepath && currentFilepath.set(frame.filepath));
|
||||||
|
|
||||||
|
$: currentDelta = $frame?.deltas[$frame?.deltas.length - 1];
|
||||||
|
$: {
|
||||||
|
const timestamp = currentDelta?.timestampMs;
|
||||||
|
if (timestamp) {
|
||||||
|
currentTimestamp.set(timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// scroller
|
// scroller
|
||||||
const maxInput = derived(richSessions, (sessions) =>
|
const maxInput = derived(richSessions, (sessions) =>
|
||||||
sessions ? sessions.flatMap((session) => session.deltas).length : 0
|
sessions ? sessions.flatMap((session) => session.deltas).length : 0
|
||||||
@ -182,17 +191,17 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(() =>
|
onMount(() =>
|
||||||
tinykeys(window, {
|
unsubscribe(
|
||||||
ArrowRight: gotoNextDelta,
|
hotkeys.on('ArrowRight', () => gotoNextDelta()),
|
||||||
ArrowLeft: gotoPrevDelta,
|
hotkeys.on('ArrowLeft', () => gotoPrevDelta()),
|
||||||
Space: () => {
|
hotkeys.on('Space', () => {
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
stop();
|
stop();
|
||||||
} else {
|
} else {
|
||||||
play();
|
play();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
)
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -218,6 +227,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if currentDelta}
|
||||||
<div
|
<div
|
||||||
id="info"
|
id="info"
|
||||||
class="w-content absolute bottom-[86px] ml-2 flex max-w-full gap-2 rounded-full bg-zinc-900/80 py-2 px-4 shadow"
|
class="w-content absolute bottom-[86px] ml-2 flex max-w-full gap-2 rounded-full bg-zinc-900/80 py-2 px-4 shadow"
|
||||||
@ -232,9 +242,12 @@
|
|||||||
</span>
|
</span>
|
||||||
<span class="whitespace-nowrap text-zinc-500">
|
<span class="whitespace-nowrap text-zinc-500">
|
||||||
–
|
–
|
||||||
{new Date($frame.deltas[$frame.deltas.length - 1].timestampMs).toLocaleString('en-US')}
|
{currentDelta.timestampMs}
|
||||||
|
–
|
||||||
|
{new Date(currentDelta.timestampMs).toLocaleString('en-US')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
id="controls"
|
id="controls"
|
||||||
|
Loading…
Reference in New Issue
Block a user