mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-02 18:41:35 +08:00
fix: add fallback for crypto.randomUUID() on older WebViews
crypto.randomUUID() is not available on older systems (macOS < 12.3, Safari < 15.4). This caused "crypto.randomUUID is not a function" error when adding providers. - Add generateUUID() utility with getRandomValues() fallback - Provide user-friendly error message if crypto API unavailable
This commit is contained in:
@@ -4,6 +4,7 @@ import { toast } from "sonner";
|
||||
import { providersApi, settingsApi, type AppId } from "@/lib/api";
|
||||
import type { Provider, Settings } from "@/types";
|
||||
import { extractErrorMessage } from "@/utils/errorUtils";
|
||||
import { generateUUID } from "@/utils/uuid";
|
||||
|
||||
export const useAddProviderMutation = (appId: AppId) => {
|
||||
const queryClient = useQueryClient();
|
||||
@@ -13,7 +14,7 @@ export const useAddProviderMutation = (appId: AppId) => {
|
||||
mutationFn: async (providerInput: Omit<Provider, "id">) => {
|
||||
const newProvider: Provider = {
|
||||
...providerInput,
|
||||
id: crypto.randomUUID(),
|
||||
id: generateUUID(),
|
||||
createdAt: Date.now(),
|
||||
};
|
||||
await providersApi.add(newProvider, appId);
|
||||
|
||||
Reference in New Issue
Block a user