Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Type the modals correctly #5239

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/desktop/src/lib/commit/CommitCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

let isUndoable = commit instanceof DetailedCommit;

let commitMessageModal: Modal;
let commitMessageModal: ReturnType<typeof Modal> | undefined;
let commitMessageValid = false;
let description = '';

Expand All @@ -98,7 +98,7 @@

description = commit.description;

commitMessageModal.show();
commitMessageModal?.show();
}

function submitCommitMessageModal() {
Expand All @@ -108,7 +108,7 @@
branchController.updateCommitMessage(branch.id, commit.id, description);
}

commitMessageModal.close();
commitMessageModal?.close();
}

const commitShortSha = commit.id.substring(0, 7);
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/lib/commit/StackingCommitCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

let isUndoable = commit instanceof DetailedCommit && type !== 'remote';

let commitMessageModal: Modal;
let commitMessageModal: ReturnType<typeof Modal> | undefined;
let commitMessageValid = $state(false);
let description = $state('');

Expand All @@ -106,7 +106,7 @@

description = commit.description;

commitMessageModal.show();
commitMessageModal?.show();
}

function submitCommitMessageModal() {
Expand All @@ -116,7 +116,7 @@
branchController.updateCommitMessage(branch.id, commit.id, description);
}

commitMessageModal.close();
commitMessageModal?.close();
}

const commitShortSha = commit.id.substring(0, 7);
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/components/NotOnGitButlerBranch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
const project = getContext(Project);

let isDeleting = false;
let deleteConfirmationModal: RemoveProjectButton;
let deleteConfirmationModal: ReturnType<typeof RemoveProjectButton> | undefined;

async function onDeleteClicked() {
if (project) {
isDeleting = true;
try {
deleteConfirmationModal.close();
deleteConfirmationModal?.close();
await projectsService.deleteProject(project.id);
toasts.success('Project deleted');
goto('/', { invalidateAll: true });
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/components/ProblemLoadingRepo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
const project = getContext(Project);

let loading = false;
let deleteConfirmationModal: RemoveProjectButton;
let deleteConfirmationModal: ReturnType<typeof RemoveProjectButton> | undefined;

async function onDeleteClicked() {
loading = true;
try {
deleteConfirmationModal.close();
deleteConfirmationModal?.close();
await projectsService.deleteProject(project.id);
toasts.success('Project deleted');
goto('/');
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/lib/components/ShareIssueModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
const user = getContextStore(User);

export function show() {
modal.show();
modal?.show();
}

async function gitIndexLength() {
Expand All @@ -36,7 +36,7 @@
});
}

let modal: Modal;
let modal: ReturnType<typeof Modal> | undefined;

let messageInputValue = '';
let emailInputValue = '';
Expand Down Expand Up @@ -140,7 +140,7 @@

function close() {
reset();
modal.close();
modal?.close();
}

onMount(() => {
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/file/FileContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
const project = getContext(Project);
const userSettings = getContextStoreBySymbol<Settings, Writable<Settings>>(SETTINGS);

let confirmationModal: Modal;
let confirmationModal: ReturnType<typeof Modal> | undefined;
let contextMenu: ReturnType<typeof ContextMenu>;

function isDeleted(item: any): boolean {
Expand Down Expand Up @@ -66,7 +66,7 @@
<ContextMenuItem
label="Discard changes"
onclick={() => {
confirmationModal.show(item);
confirmationModal?.show(item);
contextMenu.close();
}}
/>
Expand Down
10 changes: 5 additions & 5 deletions apps/desktop/src/lib/hunk/HunkContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
const branchController = getContext(BranchController);
const userSettings = getContextStoreBySymbol<Settings, Writable<Settings>>(SETTINGS);

let contextMenu: ReturnType<typeof ContextMenu>;
let contextMenu: ReturnType<typeof ContextMenu> | undefined;

export function open(e: MouseEvent, item: any) {
contextMenu.open(e, item);
contextMenu?.open(e, item);
}

export function close() {
contextMenu.close();
contextMenu?.close();
}
</script>

Expand All @@ -40,7 +40,7 @@
label="Discard"
onclick={() => {
branchController.unapplyHunk(item.hunk);
contextMenu.close();
contextMenu?.close();
}}
/>
{/if}
Expand All @@ -52,7 +52,7 @@
openExternalUrl(
`${$userSettings.defaultCodeEditor.schemeIdentifer}://file${projectPath}/${filePath}:${item.lineNumber}`
);
contextMenu.close();
contextMenu?.close();
}}
/>
{/if}
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/lib/pr/CopyLinkContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

const { target, url }: { target: HTMLElement | undefined; url: string } = $props();

let menu: ReturnType<typeof ContextMenu>;
let menu: ReturnType<typeof ContextMenu> | undefined;

export function openByMouse(e: MouseEvent) {
menu.open(e);
menu?.open(e);
}
</script>

Expand All @@ -19,7 +19,7 @@
label="Copy to Clipbaord"
onclick={() => {
copyToClipboard(url);
menu.close();
menu?.close();
}}
/>
</ContextMenuSection>
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/pr/MergeButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
const dispatch = createEventDispatcher<{ click: { method: MergeMethod } }>();
const action = persistedAction(projectId);

let dropDown: DropDownButton;
let dropDown: ReturnType<typeof DropDownButton> | undefined;

const labels = {
[MergeMethod.Merge]: 'Merge pull request',
Expand Down Expand Up @@ -49,7 +49,7 @@
label={labels[method]}
onclick={() => {
$action = method;
dropDown.close();
dropDown?.close();
}}
/>
{/each}
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/lib/settings/GithubIntegration.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
let loading = false;
let userCode = '';
let deviceCode = '';
let gitHubOauthModal: Modal;
let gitHubOauthModal: ReturnType<typeof Modal> | undefined;

function gitHubStartOauth() {
initDeviceOauth().then((verification) => {
userCode = verification.user_code;
deviceCode = verification.device_code;
gitHubOauthModal.show();
gitHubOauthModal?.show();
});
}

Expand All @@ -52,7 +52,7 @@
console.error(err);
toasts.error('GitHub authentication failed');
} finally {
gitHubOauthModal.close();
gitHubOauthModal?.close();
loading = false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/routes/settings/profile/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

$: userPicture = $user?.picture;

let deleteConfirmationModal: Modal;
let deleteConfirmationModal: ReturnType<typeof Modal> | undefined;

$: if ($user && !loaded) {
loaded = true;
Expand Down Expand Up @@ -84,7 +84,7 @@
console.error(err);
showError('Failed to delete project', err);
} finally {
deleteConfirmationModal.close();
deleteConfirmationModal?.close();
isDeleting = false;
}
}
Expand Down Expand Up @@ -145,7 +145,7 @@
Your code remains safe. it only clears the configuration.
</svelte:fragment>

<Button style="error" kind="soft" onclick={() => deleteConfirmationModal.show()}>
<Button style="error" kind="soft" onclick={() => deleteConfirmationModal?.show()}>
Remove projects…
</Button>

Expand Down