Skip to content

Commit 77865ea

Browse files
committed
Make rtkq fetch return value or throw
There was only one call site where other properties than data was accessed, we should just keep the api simple when using the promise based requests.
1 parent a95da6f commit 77865ea

28 files changed

+79
-124
lines changed

apps/desktop/src/components/BranchCard.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106
if (args.type === 'draft-branch') {
107107
uiState.global.draftBranchName.set(title);
108108
const normalized = await stackService.normalizeBranchName(title);
109-
if (normalized.data) {
110-
uiState.global.draftBranchName.set(normalized.data);
109+
if (normalized) {
110+
uiState.global.draftBranchName.set(normalized);
111111
}
112112
} else if (args.type === 'stack-branch') {
113113
updateName({

apps/desktop/src/components/GithubIntegration.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
// After we call setUser, we want to re-clone the user store, as the userService itself sets the user store
5454
mutableUser = structuredClone($user);
5555
// TODO: Remove setting of gh username since it isn't used anywhere.
56-
const githubUsername = await githubUserService.fetchGitHubLogin();
57-
mutableUser.github_username = githubUsername.data?.name || undefined;
56+
const githbLogin = await githubUserService.fetchGitHubLogin();
57+
mutableUser.github_username = githbLogin.name || undefined;
5858
userService.setUser(mutableUser);
5959
toasts.success('GitHub authenticated');
6060
} catch (err: any) {

apps/desktop/src/components/HunkContextMenu.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@
8989
label="Open in {$userSettings.defaultCodeEditor.displayName}"
9090
onclick={async () => {
9191
const project = await projectService.fetchProject(projectId);
92-
if (project.data?.path) {
92+
if (project.path) {
9393
const path = getEditorUri({
9494
schemeId: $userSettings.defaultCodeEditor.schemeIdentifer,
95-
path: [vscodePath(project.data.path), filePath],
95+
path: [vscodePath(project.path), filePath],
9696
line: item.beforeLineNumber ?? item.afterLineNumber
9797
});
9898
openExternalUrl(path);

apps/desktop/src/components/MultiStackCreateNew.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
109109
async function showAndPrefillName() {
110110
createRefModal?.show();
111-
createRefName = (await stackService.newBranchName(projectId))?.data ?? '';
111+
createRefName = await stackService.newBranchName(projectId);
112112
// Reset selected stack to default
113113
selectedStackId = undefined;
114114
}

apps/desktop/src/components/PrTemplateSection.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
3232
async function selectTemplate(newPath: string) {
3333
const template = await stackService.template(projectId, forgeName, newPath);
34-
if (template.data) {
34+
if (template) {
3535
path.set(newPath);
36-
onselect(template.data);
36+
onselect(template);
3737
}
3838
}
3939

apps/desktop/src/components/ProjectSettingsMenuAction.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
});
2727
2828
shortcutService.on('open-in-vscode', async () => {
29-
const result = await projectsService.fetchProject(projectId);
30-
const project = result.data;
29+
const project = await projectsService.fetchProject(projectId);
3130
if (!project) {
3231
throw new Error(`Project not found: ${projectId}`);
3332
}

apps/desktop/src/components/ReviewCreation.svelte

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@
127127
128128
async function getDefaultBody(commits: Commit[]): Promise<string> {
129129
if ($templateEnabled && $templatePath) {
130-
const result = await stackService.template(projectId, forge.current.name, $templatePath);
131-
if (result.data) {
132-
return result.data;
133-
}
130+
return await stackService.template(projectId, forge.current.name, $templatePath);
134131
}
135132
if (commits.length === 1) {
136133
return splitMessage(commits[0]!.message).description;

apps/desktop/src/components/StackDraft.svelte

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,9 @@
2020
const [uiState, stackService] = inject(UiState, StackService);
2121
const draftBranchName = $derived(uiState.global.draftBranchName);
2222
23-
// Automatic branch name suggested by back end.
24-
let newName = $state('');
2523
let draftPanelEl: HTMLDivElement | undefined = $state();
2624
27-
const newNameResult = stackService.newBranchName(projectId);
28-
newNameResult.then((name) => {
29-
newName = name.data || '';
30-
});
31-
32-
$effect(() => {
33-
if (newName && !draftBranchName.current) {
34-
draftBranchName.set(newName);
35-
}
36-
});
37-
38-
const branchName = $derived(draftBranchName.current || newName);
25+
const newNameResult = $derived(stackService.newBranchName(projectId));
3926
4027
onMount(() => {
4128
if (draftPanelEl) {
@@ -56,17 +43,20 @@
5643
<div class="new-commit-view" data-testid={TestId.NewCommitView}>
5744
<NewCommitView {projectId} />
5845
</div>
59-
<BranchCard
60-
type="draft-branch"
61-
{projectId}
62-
{branchName}
63-
readonly={false}
64-
lineColor="var(--clr-commit-local)"
65-
>
66-
{#snippet branchContent()}
67-
<CommitGoesHere commitId={undefined} selected last />
68-
{/snippet}
69-
</BranchCard>
46+
{#await newNameResult then newName}
47+
{@const branchName = draftBranchName.current || newName}
48+
<BranchCard
49+
type="draft-branch"
50+
{projectId}
51+
{branchName}
52+
readonly={false}
53+
lineColor="var(--clr-commit-local)"
54+
>
55+
{#snippet branchContent()}
56+
<CommitGoesHere commitId={undefined} selected last />
57+
{/snippet}
58+
</BranchCard>
59+
{/await}
7060
<Resizer
7161
persistId="resizer-darft-panel"
7262
viewport={draftPanelEl}

apps/desktop/src/components/StackView.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@
216216
if (branchName && commitId) {
217217
if (upstream) {
218218
stackService.fetchUpstreamCommitById(projectId, stack.id, commitId).then((result) => {
219-
if (!result.data) {
219+
if (!result) {
220220
selection.set(undefined);
221221
}
222222
});
223223
} else {
224224
stackService.fetchCommitById(projectId, stack.id, commitId).then((result) => {
225-
if (!result.data) {
225+
if (!result) {
226226
selection.set(undefined);
227227
}
228228
});

apps/desktop/src/components/TargetCommitList.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
6565
async function getPage(commitId: string | undefined) {
6666
const result = await stackService.targetCommits(projectId, commitId, 20);
67-
return result.data || [];
67+
return result || [];
6868
}
6969
7070
onMount(() => {

0 commit comments

Comments
 (0)