feat: update projectCurrentCommitMessage function to include branchId parameter and use it in relevant places

This commit is contained in:
Kiril Videlov 2024-02-17 21:13:02 +01:00 committed by Kiril Videlov
parent 029377be06
commit 64ee34e0a9
4 changed files with 12 additions and 16 deletions

View File

@ -3,7 +3,7 @@
import Button from '$lib/components/Button.svelte';
import Tag from '$lib/components/Tag.svelte';
import TimeAgo from '$lib/components/TimeAgo.svelte';
import { projectCurrentCommitMessage, projectLastCommitMessage } from '$lib/config/config';
import { projectCurrentCommitMessage } from '$lib/config/config';
import { draggable } from '$lib/dragging/draggable';
import { draggableCommit, nonDraggable } from '$lib/dragging/draggables';
import { openExternalUrl } from '$lib/utils/url';
@ -20,10 +20,10 @@
export let resetHeadCommit: () => void | undefined = () => undefined;
export let isUnapplied = false;
export let selectedFiles: Writable<(LocalFile | RemoteFile)[]>;
export let branchId: string | undefined = undefined;
const selectedOwnership = writable(Ownership.default());
const currentCommitMessage = projectCurrentCommitMessage(projectId);
const lastCommitMessage = projectLastCommitMessage(projectId);
const currentCommitMessage = projectCurrentCommitMessage(projectId, branchId || '');
let showFiles = false;
@ -58,7 +58,7 @@
border
clickable
on:click={(e) => {
currentCommitMessage.set($lastCommitMessage);
currentCommitMessage.set(commit.description);
e.stopPropagation();
resetHeadCommit();
}}>Undo</Tag

View File

@ -10,8 +10,7 @@
projectCommitGenerationExtraConcise,
projectCommitGenerationUseEmojis,
projectRunCommitHooks,
projectCurrentCommitMessage,
projectLastCommitMessage
projectCurrentCommitMessage
} from '$lib/config/config';
import { persisted } from '$lib/persisted/persisted';
import * as toasts from '$lib/utils/toasts';
@ -41,8 +40,7 @@
const aiGenEnabled = projectAiGenEnabled(projectId);
const runCommitHooks = projectRunCommitHooks(projectId);
const currentCommitMessage = projectCurrentCommitMessage(projectId);
const lastCommitMessage = projectLastCommitMessage(projectId);
const currentCommitMessage = projectCurrentCommitMessage(projectId, branch.id);
export const expanded = persisted<boolean>(false, 'commitBoxExpanded_' + branch.id);
let commitMessage: string = get(currentCommitMessage) || '';
@ -64,7 +62,6 @@
branchController
.commitBranch(branch.id, commitMessage, $selectedOwnership.toString(), $runCommitHooks)
.then(() => {
lastCommitMessage.set(commitMessage);
commitMessage = '';
currentCommitMessage.set('');
})

View File

@ -146,6 +146,7 @@
{resetHeadCommit}
{isUnapplied}
{selectedFiles}
branchId={branch.id}
/>
</div>
<!-- <div class="reset-head">

View File

@ -51,12 +51,10 @@ export function projectLaneCollapsed(projectId: string, laneId: string): Persist
return persisted(false, key + projectId + '_' + laneId);
}
export function projectCurrentCommitMessage(projectId: string): Persisted<string> {
export function projectCurrentCommitMessage(
projectId: string,
branchId: string
): Persisted<string> {
const key = 'projectCurrentCommitMessage_';
return persisted('', key + projectId);
}
export function projectLastCommitMessage(projectId: string): Persisted<string> {
const key = 'projectLastCommitMessage_';
return persisted('', key + projectId);
return persisted('', key + projectId + '_' + branchId);
}