Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,18 @@
}

return {
total,
total: variables.length,
variables
};
}

async function ensureAllVariablesLoaded() {
if (fullVariableList && fullVariableList.total === variableList.total) return;
if (
fullVariableList &&
fullVariableList.variables.length >= variableList.variables.length
) {
return;
}
Comment on lines 108 to +114
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 When backendPagination is true the raw editor and import modal both call ensureAllVariablesLoaded, which must load every variable regardless of the current page. The new guard fullVariableList.variables.length >= variableList.variables.length compares against the current page size (e.g. 10), not the server total. A stale fullVariableList with, say, 50 of 100 variables would satisfy 50 >= 10 and return early, leaving the editor with incomplete data. Comparing against variableList.total (the server total) correctly gates on whether all variables are present.

Suggested change
async function ensureAllVariablesLoaded() {
if (fullVariableList && fullVariableList.total === variableList.total) return;
if (
fullVariableList &&
fullVariableList.variables.length >= variableList.variables.length
) {
return;
}
async function ensureAllVariablesLoaded() {
if (
fullVariableList &&
fullVariableList.variables.length >= variableList.total
) {
return;
}


fullVariableList = await loadAllVariables();
}
Expand Down Expand Up @@ -338,14 +343,15 @@
previousVariableList = variableList;
}

$: if (fullVariableList && fullVariableList.total !== variableList.total) {
$: if (fullVariableList && fullVariableList.variables.length < variableList.variables.length) {
fullVariableList = undefined;
}

$: editorVariableList = fullVariableList ?? allVariableList ?? variableList;
$: displayedVariables = backendPagination
? variableList.variables
: variableList.variables.slice(offset, offset + limit);
$: variableCount = backendPagination ? variableList.total : variableList.variables.length;

$: hasConflictOnPage = globalVariableList
? displayedVariables.filter((variable) => {
Expand Down Expand Up @@ -422,7 +428,7 @@
<Icon slot="start" icon={IconUpload} /> Import .env
</Button>
</Layout.Stack>
{#if variableList.total}
{#if variableCount}
<Button
secondary
{disabled}
Expand All @@ -436,7 +442,7 @@
{/if}
</Layout.Stack>
</Layout.Stack>
{@const sum = variableList.total}
{@const sum = variableCount}
{#if sum}
<Layout.Stack gap="l">
{#if conflictVariables.length > 0}
Expand Down