Websocket basic
Websocket basic
This commit is contained in:
@@ -125,7 +125,6 @@
|
||||
longitude: gps.lng,
|
||||
},
|
||||
});
|
||||
notificationController.show({ message: 'Metadata updated please reload to apply', type: NotificationType.Info });
|
||||
} catch (error) {
|
||||
handleError(error, 'Unable to change location');
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
await api.assetApi.updateAssets({
|
||||
assetBulkUpdateDto: { ids, dateTimeOriginal },
|
||||
});
|
||||
notificationController.show({ message: 'Metadata updated please reload to apply', type: NotificationType.Info });
|
||||
notificationController.show({ message: 'Updating date please wait', type: NotificationType.Info });
|
||||
} catch (error) {
|
||||
handleError(error, 'Unable to change date');
|
||||
}
|
||||
@@ -29,7 +29,7 @@
|
||||
longitude: point.lng,
|
||||
},
|
||||
});
|
||||
notificationController.show({ message: 'Metadata updated please reload to apply', type: NotificationType.Info });
|
||||
notificationController.show({ message: 'Updating location please wait', type: NotificationType.Info });
|
||||
} catch (error) {
|
||||
handleError(error, 'Unable to update location');
|
||||
}
|
||||
32
web/src/lib/components/shared-components/update-panel.svelte
Normal file
32
web/src/lib/components/shared-components/update-panel.svelte
Normal file
@@ -0,0 +1,32 @@
|
||||
<script lang="ts">
|
||||
import { websocketStore } from '$lib/stores/websocket';
|
||||
import { notificationController, NotificationType } from './notification/notification';
|
||||
|
||||
let assetUpdateCount = 0;
|
||||
let lastAssetName;
|
||||
let timeoutId;
|
||||
|
||||
const subscribe = websocketStore.onAssetUpdate.subscribe(value => {
|
||||
if (value && value.originalFileName) {
|
||||
lastAssetName = value.originalFileName;
|
||||
assetUpdateCount++;
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = setTimeout(() => {
|
||||
if (assetUpdateCount === 1) {
|
||||
|
||||
notificationController.show({
|
||||
message: `Asset updated: ${lastAssetName}.\nPlease reload to apply changes`,
|
||||
type: NotificationType.Info,
|
||||
});
|
||||
} else {
|
||||
notificationController.show({
|
||||
message: `${assetUpdateCount} assets updated.\nPlease reload to apply changes`,
|
||||
type: NotificationType.Info,
|
||||
});
|
||||
}
|
||||
assetUpdateCount = 0;
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user