Skip to content

Commit 9f9f06a

Browse files
committed
♻️ Skip update if submission status is same (#1706)
1 parent 39c8566 commit 9f9f06a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/lib/components/SubmissionStatus/UpdatingDropdown.svelte

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@
106106
// Cancel the default form submission.
107107
cancel();
108108
109+
if (isSame(submissionStatus, taskResult)) {
110+
console.log('Skipping: Submission status already set to', submissionStatus.labelName);
111+
112+
resetDropdown();
113+
return () => {};
114+
}
115+
109116
// Submit data manually using fetch API.
110117
fetch(action, {
111118
method: 'POST',
@@ -124,15 +131,23 @@
124131
errorMessageStore.setAndClearAfterTimeout(FAILED_TO_UPDATE_SUBMISSION_STATUS, 10000);
125132
})
126133
.finally(() => {
127-
closeDropdown();
128-
showForm = false;
134+
resetDropdown();
129135
});
130136
131137
// Do not change anything in SvelteKit.
132138
return () => {};
133139
};
134140
};
135141
142+
function isSame(submissionStatus: SubmissionStatus, taskResult: TaskResult): boolean {
143+
return submissionStatus.innerName === taskResult.status_name;
144+
}
145+
146+
function resetDropdown(): void {
147+
closeDropdown();
148+
showForm = false;
149+
}
150+
136151
function updateTaskResult(
137152
taskResult: TaskResult,
138153
submissionStatus: SubmissionStatus,

0 commit comments

Comments
 (0)