mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-25 18:42:08 +03:00
Fix "load failed" on pr creation
- rust returns null for optional values rather than undefined - add missing $derived
This commit is contained in:
parent
3c3fe9ad8b
commit
ee04556008
@ -87,7 +87,7 @@
|
||||
props.type === 'preview-series' ? props.currentSeries.name : branch.upstreamName
|
||||
);
|
||||
const baseBranchName = $derived($baseBranch.shortName);
|
||||
const currentSeries = props.type === 'preview-series' ? props.currentSeries : undefined;
|
||||
const currentSeries = $derived(props.type === 'preview-series' ? props.currentSeries : undefined);
|
||||
|
||||
let createPrDropDown = $state<ReturnType<typeof DropDownButton>>();
|
||||
const createDraft = persisted<boolean>(false, 'createDraftPr');
|
||||
@ -169,6 +169,9 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// All ids that existed prior to creating a new one (including archived).
|
||||
const priorIds = branch.series.map((series) => series.prNumber).filter(isDefined);
|
||||
|
||||
isLoading = true;
|
||||
try {
|
||||
let upstreamBranchName = upstreamName;
|
||||
@ -202,9 +205,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// All ids that existed prior to creating a new one (including archived).
|
||||
const priorIds = branch.series.map((series) => series.prNumber).filter(isDefined);
|
||||
|
||||
// Find the index of the current branch so we know where we want to point the pr.
|
||||
const branches = branch.series;
|
||||
const currentIndex = branches.findIndex((b) => b.name === currentSeries.name);
|
||||
|
@ -2,7 +2,7 @@ import 'reflect-metadata';
|
||||
import { emptyConflictEntryPresence, type ConflictEntryPresence } from '$lib/conflictEntryPresence';
|
||||
import { splitMessage } from '$lib/utils/commitMessage';
|
||||
import { hashCode } from '@gitbutler/ui/utils/string';
|
||||
import { isDefined, notNull } from '@gitbutler/ui/utils/typeguards';
|
||||
import { isDefined } from '@gitbutler/ui/utils/typeguards';
|
||||
import { Type, Transform } from 'class-transformer';
|
||||
import type { PullRequest } from '$lib/forge/interface/types';
|
||||
|
||||
@ -80,10 +80,7 @@ export class LocalFile {
|
||||
}
|
||||
|
||||
get lockedIds(): HunkLock[] {
|
||||
return this.hunks
|
||||
.flatMap((hunk) => hunk.lockedTo)
|
||||
.filter(notNull)
|
||||
.filter(isDefined);
|
||||
return this.hunks.flatMap((hunk) => hunk.lockedTo).filter(isDefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
/**
|
||||
* Not undefined and not null. This is less prone for errors than checking undefined
|
||||
* and not null separately.
|
||||
*/
|
||||
export function isDefined<T>(file: T | undefined | null): file is T {
|
||||
return file !== undefined;
|
||||
}
|
||||
|
||||
export function notNull<T>(file: T | undefined | null): file is T {
|
||||
return file !== null;
|
||||
return file !== undefined && file !== null;
|
||||
}
|
||||
|
||||
export type UnknownObject = Record<string, unknown>;
|
||||
|
Loading…
Reference in New Issue
Block a user