mirror of
https://github.com/immich-app/immich.git
synced 2025-09-29 15:31:13 -04:00
fix(web): cancel uploads on logout (#21760)
This commit is contained in:
parent
00c88b2636
commit
e52cc259d5
@ -1,11 +1,16 @@
|
||||
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||
import { uploadAssetsStore } from '$lib/stores/upload';
|
||||
import { getSupportedMediaTypes, type ServerMediaTypesResponseDto } from '@immich/sdk';
|
||||
|
||||
class UploadManager {
|
||||
mediaTypes = $state<ServerMediaTypesResponseDto>({ image: [], sidecar: [], video: [] });
|
||||
|
||||
constructor() {
|
||||
eventManager.on('app.init', () => void this.#loadExtensions());
|
||||
eventManager.on('app.init', () => void this.#loadExtensions()).on('auth.logout', () => void this.reset());
|
||||
}
|
||||
|
||||
reset() {
|
||||
uploadAssetsStore.reset();
|
||||
}
|
||||
|
||||
async #loadExtensions() {
|
||||
|
@ -2,6 +2,7 @@ import { authManager } from '$lib/managers/auth-manager.svelte';
|
||||
import { uploadManager } from '$lib/managers/upload-manager.svelte';
|
||||
import { UploadState } from '$lib/models/upload-asset';
|
||||
import { uploadAssetsStore } from '$lib/stores/upload';
|
||||
import { user } from '$lib/stores/user.store';
|
||||
import { uploadRequest } from '$lib/utils';
|
||||
import { addAssetsToAlbum } from '$lib/utils/asset-utils';
|
||||
import { ExecutorQueue } from '$lib/utils/executor-queue';
|
||||
@ -231,6 +232,11 @@ async function fileUploader({
|
||||
|
||||
return responseData.id;
|
||||
} catch (error) {
|
||||
// ignore errors if the user logs out during uploads
|
||||
if (!get(user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const errorMessage = handleError(error, $t('errors.unable_to_upload_file'));
|
||||
uploadAssetsStore.track('error');
|
||||
uploadAssetsStore.updateItem(deviceAssetId, { state: UploadState.ERROR, error: errorMessage });
|
||||
|
Loading…
x
Reference in New Issue
Block a user