mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
fix(ui): do not use crypto.randomUUID
This API is not available in all browsers. Also add an eslint rule to prevent usage in the future.
This commit is contained in:
@@ -16,6 +16,14 @@ module.exports = {
|
||||
'no-promise-executor-return': 'error',
|
||||
// https://eslint.org/docs/latest/rules/require-await
|
||||
'require-await': 'error',
|
||||
'no-restricted-properties': [
|
||||
'error',
|
||||
{
|
||||
object: 'crypto',
|
||||
property: 'randomUUID',
|
||||
message: 'Use of crypto.randomUUID is not allowed as it is not available in all browsers.',
|
||||
},
|
||||
],
|
||||
},
|
||||
overrides: [
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { UseToastOptions } from '@invoke-ai/ui-library';
|
||||
import { createStandaloneToast, theme, TOAST_OPTIONS } from '@invoke-ai/ui-library';
|
||||
import { nanoid } from 'features/controlLayers/konva/util';
|
||||
import { map } from 'nanostores';
|
||||
|
||||
const toastApi = createStandaloneToast({
|
||||
@@ -67,7 +68,7 @@ const getGetState = (id: string) => () => $toastMap.get()[id] ?? null;
|
||||
*/
|
||||
export const toast = (arg: ToastArg): ToastApi => {
|
||||
// All toasts need an id, set a random one if not provided
|
||||
const id = arg.id ?? crypto.randomUUID();
|
||||
const id = arg.id ?? nanoid();
|
||||
if (!arg.id) {
|
||||
arg.id = id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user