mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-21 00:21:35 +03:00
feat: the commit message will no longer be lost during navigation
This commit is contained in:
parent
f252d0c8f0
commit
2a48b7f072
@ -9,7 +9,9 @@
|
|||||||
projectAiGenEnabled,
|
projectAiGenEnabled,
|
||||||
projectCommitGenerationExtraConcise,
|
projectCommitGenerationExtraConcise,
|
||||||
projectCommitGenerationUseEmojis,
|
projectCommitGenerationUseEmojis,
|
||||||
projectRunCommitHooks
|
projectRunCommitHooks,
|
||||||
|
projectCurrentCommitMessage,
|
||||||
|
projectLastCommitMessage
|
||||||
} from '$lib/config/config';
|
} from '$lib/config/config';
|
||||||
import { persisted } from '$lib/persisted/persisted';
|
import { persisted } from '$lib/persisted/persisted';
|
||||||
import * as toasts from '$lib/utils/toasts';
|
import * as toasts from '$lib/utils/toasts';
|
||||||
@ -18,6 +20,7 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
import { invoke } from '@tauri-apps/api/tauri';
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
import { quintOut } from 'svelte/easing';
|
import { quintOut } from 'svelte/easing';
|
||||||
|
import { get } from 'svelte/store';
|
||||||
import { slide } from 'svelte/transition';
|
import { slide } from 'svelte/transition';
|
||||||
import type { User, getCloudApiClient } from '$lib/backend/cloud';
|
import type { User, getCloudApiClient } from '$lib/backend/cloud';
|
||||||
import type { BranchController } from '$lib/vbranches/branchController';
|
import type { BranchController } from '$lib/vbranches/branchController';
|
||||||
@ -38,11 +41,17 @@
|
|||||||
|
|
||||||
const aiGenEnabled = projectAiGenEnabled(projectId);
|
const aiGenEnabled = projectAiGenEnabled(projectId);
|
||||||
const runCommitHooks = projectRunCommitHooks(projectId);
|
const runCommitHooks = projectRunCommitHooks(projectId);
|
||||||
|
const currentCommitMessage = projectCurrentCommitMessage(projectId);
|
||||||
|
const lastCommitMessage = projectLastCommitMessage(projectId);
|
||||||
export const expanded = persisted<boolean>(false, 'commitBoxExpanded_' + branch.id);
|
export const expanded = persisted<boolean>(false, 'commitBoxExpanded_' + branch.id);
|
||||||
|
|
||||||
let commitMessage: string;
|
let commitMessage: string = get(currentCommitMessage) || '';
|
||||||
let isCommitting = false;
|
let isCommitting = false;
|
||||||
let textareaElement: HTMLTextAreaElement;
|
let textareaElement: HTMLTextAreaElement;
|
||||||
|
$: if (textareaElement && commitMessage && expanded) {
|
||||||
|
textareaElement.style.height = 'auto';
|
||||||
|
textareaElement.style.height = `${textareaElement.scrollHeight + 2}px`;
|
||||||
|
}
|
||||||
|
|
||||||
const focusTextareaOnMount = (el: HTMLTextAreaElement) => {
|
const focusTextareaOnMount = (el: HTMLTextAreaElement) => {
|
||||||
if (el) {
|
if (el) {
|
||||||
@ -55,7 +64,9 @@
|
|||||||
branchController
|
branchController
|
||||||
.commitBranch(branch.id, commitMessage, $selectedOwnership.toString(), $runCommitHooks)
|
.commitBranch(branch.id, commitMessage, $selectedOwnership.toString(), $runCommitHooks)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
lastCommitMessage.set(commitMessage);
|
||||||
commitMessage = '';
|
commitMessage = '';
|
||||||
|
currentCommitMessage.set('');
|
||||||
})
|
})
|
||||||
.finally(() => (isCommitting = false));
|
.finally(() => (isCommitting = false));
|
||||||
}
|
}
|
||||||
@ -96,6 +107,7 @@
|
|||||||
const summary = firstNewLine > -1 ? message.slice(0, firstNewLine).trim() : message;
|
const summary = firstNewLine > -1 ? message.slice(0, firstNewLine).trim() : message;
|
||||||
const description = firstNewLine > -1 ? message.slice(firstNewLine + 1).trim() : '';
|
const description = firstNewLine > -1 ? message.slice(firstNewLine + 1).trim() : '';
|
||||||
commitMessage = description.length > 0 ? `${summary}\n\n${description}` : summary;
|
commitMessage = description.length > 0 ? `${summary}\n\n${description}` : summary;
|
||||||
|
currentCommitMessage.set(commitMessage);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
textareaElement.focus();
|
textareaElement.focus();
|
||||||
@ -124,6 +136,7 @@
|
|||||||
use:focusTextareaOnMount
|
use:focusTextareaOnMount
|
||||||
on:input={useAutoHeight}
|
on:input={useAutoHeight}
|
||||||
on:focus={useAutoHeight}
|
on:focus={useAutoHeight}
|
||||||
|
on:change={() => currentCommitMessage.set(commitMessage)}
|
||||||
spellcheck={false}
|
spellcheck={false}
|
||||||
class="commit-box__textarea text-base-body-13"
|
class="commit-box__textarea text-base-body-13"
|
||||||
rows="1"
|
rows="1"
|
||||||
|
@ -50,3 +50,13 @@ export function projectLaneCollapsed(projectId: string, laneId: string): Persist
|
|||||||
const key = 'projectLaneCollapsed_';
|
const key = 'projectLaneCollapsed_';
|
||||||
return persisted(false, key + projectId + '_' + laneId);
|
return persisted(false, key + projectId + '_' + laneId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function projectCurrentCommitMessage(projectId: string): Persisted<string> {
|
||||||
|
const key = 'projectCurrentCommitMessage_';
|
||||||
|
return persisted('', key + projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function projectLastCommitMessage(projectId: string): Persisted<string> {
|
||||||
|
const key = 'projectLastCommitMessage_';
|
||||||
|
return persisted('', key + projectId);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user