diff --git a/src/components/PersonalSettings.vue b/src/components/PersonalSettings.vue index c44b8714..6a0392a1 100644 --- a/src/components/PersonalSettings.vue +++ b/src/components/PersonalSettings.vue @@ -827,10 +827,16 @@ export default { if (!this.pickerSessionId) { return } + + // Save the picker session ID to throw out the response if it changed since the request was made + // There's a race condition if onImportPhotos resolved in the meantime + const pickerSessionIdOfRequest = this.pickerSessionId + const url = generateUrl('/apps/integration_google/picker-session') axios.get(url, { params: { sessionId: this.pickerSessionId } }) .then((response) => { - if (response.data.mediaItemsSet === true && !this.startingPhotoImport) { + // Check pickerSessionId again to fix race condition (could have changed in the meantime) + if (response.data.mediaItemsSet === true && !this.startingPhotoImport && (pickerSessionIdOfRequest === this.pickerSessionId)) { this.onImportPhotos() } })