mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-29 04:21:40 +03:00
fix linter
This commit is contained in:
parent
13456d0398
commit
acd4035451
@ -9,49 +9,49 @@ export type OperationInsert = { insert: [number, string] };
|
||||
export type Operation = OperationDelete | OperationInsert;
|
||||
|
||||
export namespace Operation {
|
||||
export const isDelete = (operation: Operation): operation is OperationDelete =>
|
||||
'delete' in operation;
|
||||
export const isDelete = (operation: Operation): operation is OperationDelete =>
|
||||
'delete' in operation;
|
||||
|
||||
export const isInsert = (operation: Operation): operation is OperationInsert =>
|
||||
'insert' in operation;
|
||||
export const isInsert = (operation: Operation): operation is OperationInsert =>
|
||||
'insert' in operation;
|
||||
}
|
||||
|
||||
export type Delta = { timestampMs: number; operations: Operation[] };
|
||||
|
||||
export type DeltasEvent = {
|
||||
deltas: Delta[];
|
||||
filePath: string;
|
||||
deltas: Delta[];
|
||||
filePath: string;
|
||||
};
|
||||
|
||||
export const list = (params: { projectId: string; sessionId: string }) =>
|
||||
invoke<Record<string, Delta[]>>('list_deltas', params);
|
||||
invoke<Record<string, Delta[]>>('list_deltas', params);
|
||||
|
||||
export const subscribe = (
|
||||
params: { projectId: string; sessionId: string },
|
||||
callback: (filepath: string, deltas: Delta[]) => void
|
||||
params: { projectId: string; sessionId: string },
|
||||
callback: (filepath: string, deltas: Delta[]) => void
|
||||
) => {
|
||||
log.info(`Subscribing to deltas for ${params.projectId}, ${params.sessionId}`);
|
||||
return appWindow.listen<DeltasEvent>(
|
||||
`project://${params.projectId}/sessions/${params.sessionId}/deltas`,
|
||||
(event) => {
|
||||
log.info(
|
||||
`Received deltas for ${params.projectId}, ${params.sessionId}, ${event.payload.filePath}`
|
||||
);
|
||||
callback(event.payload.filePath, event.payload.deltas);
|
||||
}
|
||||
);
|
||||
log.info(`Subscribing to deltas for ${params.projectId}, ${params.sessionId}`);
|
||||
return appWindow.listen<DeltasEvent>(
|
||||
`project://${params.projectId}/sessions/${params.sessionId}/deltas`,
|
||||
(event) => {
|
||||
log.info(
|
||||
`Received deltas for ${params.projectId}, ${params.sessionId}, ${event.payload.filePath}`
|
||||
);
|
||||
callback(event.payload.filePath, event.payload.deltas);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default async (params: { projectId: string; sessionId: string }) => {
|
||||
const init = await list(params);
|
||||
const init = await list(params);
|
||||
|
||||
const store = writable<Record<string, Delta[]>>(init);
|
||||
subscribe(params, (filepath, newDeltas) =>
|
||||
store.update((deltas) => ({
|
||||
...deltas,
|
||||
[filepath]: newDeltas
|
||||
}))
|
||||
);
|
||||
const store = writable<Record<string, Delta[]>>(init);
|
||||
subscribe(params, (filepath, newDeltas) =>
|
||||
store.update((deltas) => ({
|
||||
...deltas,
|
||||
[filepath]: newDeltas
|
||||
}))
|
||||
);
|
||||
|
||||
return store as Readable<Record<string, Delta[]>>;
|
||||
return store as Readable<Record<string, Delta[]>>;
|
||||
};
|
||||
|
@ -9,7 +9,7 @@ export type Status = {
|
||||
status: string;
|
||||
};
|
||||
|
||||
const listFiles = (params: { projectId: string; }) =>
|
||||
const listFiles = (params: { projectId: string }) =>
|
||||
invoke<Record<string, string>>('git_status', params);
|
||||
|
||||
function convertToStatuses(statusesGit: Record<string, string>): Status[] {
|
||||
@ -17,21 +17,21 @@ function convertToStatuses(statusesGit: Record<string, string>): Status[] {
|
||||
return {
|
||||
path: status[0],
|
||||
status: status[1]
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export default async (params: { projectId: string }) => {
|
||||
const statusesGit = await listFiles(params);
|
||||
const statuses = convertToStatuses(statusesGit)
|
||||
const statuses = convertToStatuses(statusesGit);
|
||||
|
||||
const store = writable(statuses);
|
||||
|
||||
appWindow.listen<Session>(`project://${params.projectId}/sessions`, async (event) => {
|
||||
log.info(`Status: Received sessions event, projectId: ${params.projectId}`);
|
||||
const statusesGit = await listFiles(params);
|
||||
const statuses = convertToStatuses(statusesGit)
|
||||
store.set(statuses)
|
||||
log.info(`Status: Received sessions event, projectId: ${params.projectId}`);
|
||||
const statusesGit = await listFiles(params);
|
||||
const statuses = convertToStatuses(statusesGit);
|
||||
store.set(statuses);
|
||||
});
|
||||
|
||||
return store as Readable<Status[]>;
|
||||
|
@ -41,10 +41,10 @@
|
||||
name="search"
|
||||
id="search"
|
||||
placeholder="search"
|
||||
class="block w-full pl-3 min-w-0 flex-1 rounded-none bg-zinc-900 border-r-0 rounded-l-md border-0 py-1.5 text-zinc-200 ring-1 ring-inset ring-zinc-700 placeholder:text-zinc-400 focus:ring-1 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
|
||||
class="block w-full min-w-0 flex-1 rounded-none rounded-l-md border-0 border-r-0 bg-zinc-900 py-1.5 pl-3 text-zinc-200 ring-1 ring-inset ring-zinc-700 placeholder:text-zinc-400 focus:ring-1 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
|
||||
/>
|
||||
<span
|
||||
class="inline-flex items-center rounded-r-md bg-zinc-900 border border-l-0 border-zinc-700 px-3 text-gray-500 sm:text-sm"
|
||||
class="inline-flex items-center rounded-r-md border border-l-0 border-zinc-700 bg-zinc-900 px-3 text-gray-500 sm:text-sm"
|
||||
>⌘K</span
|
||||
>
|
||||
</div>
|
||||
@ -56,7 +56,7 @@
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
class="w-6 h-6"
|
||||
class="h-6 w-6"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
|
@ -12,7 +12,7 @@ export const prerender = false;
|
||||
export const load: LayoutLoad = async ({ parent, params }) => {
|
||||
const { projects } = await parent();
|
||||
|
||||
let filesStatus = building
|
||||
const filesStatus = building
|
||||
? readable<Status[]>([])
|
||||
: await (await import('$lib/statuses')).default({ projectId: params.projectId });
|
||||
|
||||
@ -58,7 +58,7 @@ export const load: LayoutLoad = async ({ parent, params }) => {
|
||||
} else {
|
||||
dateSessions[date.getTime()] = [uiSession];
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// For each UISession in dateSessions, set the earliestDeltaTimestampMs and latestDeltaTimestampMs
|
||||
Object.keys(dateSessions).forEach((date: any) => {
|
||||
@ -71,7 +71,6 @@ export const load: LayoutLoad = async ({ parent, params }) => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
return dateSessions;
|
||||
});
|
||||
}
|
||||
|
@ -114,20 +114,20 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="mt-4 px-8 flex flex-col">
|
||||
<div class="mt-4 flex flex-col px-8">
|
||||
<h1 class="flex text-xl text-zinc-200">
|
||||
{$project?.title} <span class="text-zinc-600 ml-2">Project</span>
|
||||
{$project?.title} <span class="ml-2 text-zinc-600">Project</span>
|
||||
</h1>
|
||||
<div class="grid grid-cols-3 mt-4">
|
||||
<div class="mt-4 grid grid-cols-3">
|
||||
<div class="col-span-2 pr-6">
|
||||
<h2 class="text-lg font-bold text-zinc-500 mb-4">Recent File Changes</h2>
|
||||
<h2 class="mb-4 text-lg font-bold text-zinc-500">Recent File Changes</h2>
|
||||
{#if $dateSessions === undefined}
|
||||
<span>Loading...</span>
|
||||
{:else}
|
||||
<div class="flex flex-col space-y-4">
|
||||
{#each orderedSessions($dateSessions) as [dateMilliseconds, fileSessions]}
|
||||
<div class="flex flex-col">
|
||||
<div class="text-zinc-400 text-lg text-zinc-200 mb-1">
|
||||
<div class="mb-1 text-lg text-zinc-400 text-zinc-200">
|
||||
{new Date(parseInt(dateMilliseconds)).toLocaleDateString('en-us', {
|
||||
weekday: 'long',
|
||||
year: 'numeric',
|
||||
@ -135,10 +135,10 @@
|
||||
day: 'numeric'
|
||||
})}
|
||||
</div>
|
||||
<div class="bg-zinc-700 rounded p-4">
|
||||
<div class="rounded bg-zinc-700 p-4">
|
||||
{#each Object.entries(fileSessions) as filetime}
|
||||
<div class="flex flex-row justify-between">
|
||||
<div class="text-zinc-100 font-mono">{filetime[0]}</div>
|
||||
<div class="font-mono text-zinc-100">{filetime[0]}</div>
|
||||
<div class="text-zinc-400">{@html timestampsToSpark(filetime[1])}</div>
|
||||
</div>
|
||||
{/each}
|
||||
@ -150,11 +150,11 @@
|
||||
</div>
|
||||
<div class="col-span-1 space-y-6">
|
||||
<div>
|
||||
<h2 class="text-lg font-bold text-zinc-500 mb-2">Work in Progress</h2>
|
||||
<h2 class="mb-2 text-lg font-bold text-zinc-500">Work in Progress</h2>
|
||||
{#if $filesStatus.length == 0}
|
||||
<div class="bg-green-900 text-green-500 p-4 rounded">Everything is committed</div>
|
||||
<div class="rounded bg-green-900 p-4 text-green-500">Everything is committed</div>
|
||||
{:else}
|
||||
<div class="bg-blue-900 p-4 rounded">
|
||||
<div class="rounded bg-blue-900 p-4">
|
||||
<ul class="">
|
||||
{#each $filesStatus as activity}
|
||||
<li>
|
||||
@ -170,9 +170,9 @@
|
||||
<div>
|
||||
<h2 class="text-lg font-bold text-zinc-500">Recent Activity</h2>
|
||||
{#each recentActivity($dateSessions) as activity}
|
||||
<div class="text-zinc-400 mt-4 mb-1">
|
||||
<div class="mt-4 mb-1 text-zinc-400">
|
||||
<div class="flex flex-col">
|
||||
<div class="flex flex-row justify-between p-2 bg-zinc-700 rounded-t">
|
||||
<div class="flex flex-row justify-between rounded-t bg-zinc-700 p-2">
|
||||
<div class="text-zinc-300">
|
||||
{new Date(parseInt(activity.timestampMs)).toLocaleDateString('en-us', {
|
||||
weekday: 'long',
|
||||
@ -183,7 +183,7 @@
|
||||
</div>
|
||||
<div>{activity.type}</div>
|
||||
</div>
|
||||
<div class="bg-zinc-600 rounded-b p-2">{activity.message}</div>
|
||||
<div class="rounded-b bg-zinc-600 p-2">{activity.message}</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
|
Loading…
Reference in New Issue
Block a user