Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/hooks/stores/useCategoriesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ export function useCategoriesStore(options: UseCategoriesStoreOptions = {}) {

// Utility functions
const generateId = useCallback(() => {
return (
(crypto as { randomUUID?: () => string }).randomUUID?.() ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`
);
return typeof globalThis.crypto?.randomUUID === "function"
? globalThis.crypto.randomUUID()
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;
}, []);

const getNextColor = useCallback(() => {
Expand Down
7 changes: 3 additions & 4 deletions src/hooks/stores/useNotesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ export function useNotesStore(options: UseNotesStoreOptions = {}) {

// Utility functions
const generateId = useCallback(() => {
return (
(crypto as { randomUUID?: () => string }).randomUUID?.() ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`
);
return typeof globalThis.crypto?.randomUUID === "function"
? globalThis.crypto.randomUUID()
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;
}, []);

const sortNotes = useCallback((notesList: Note[]): Note[] => {
Expand Down
7 changes: 3 additions & 4 deletions src/hooks/stores/useRecurringTasksStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ export function useRecurringTasksStore(

// Utility functions
const generateId = useCallback(() => {
return (
(crypto as { randomUUID?: () => string }).randomUUID?.() ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`
);
return typeof globalThis.crypto?.randomUUID === "function"
? globalThis.crypto.randomUUID()
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;
}, []);

// Date calculation functions
Expand Down
7 changes: 3 additions & 4 deletions src/hooks/stores/useTasksStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ export function useTasksStore(options: UseTasksStoreOptions = {}) {

// Utility functions
const generateId = useCallback(() => {
return (
(crypto as { randomUUID?: () => string }).randomUUID?.() ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`
);
return typeof globalThis.crypto?.randomUUID === "function"
? globalThis.crypto.randomUUID()
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;
}, []);

// Task CRUD operations
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useHabitStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import {
const API_URL = "/api/habits";

const generateId = () =>
(crypto as { randomUUID?: () => string }).randomUUID?.() ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`;
typeof globalThis.crypto?.randomUUID === "function"
? globalThis.crypto.randomUUID()
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;

const useHabitStoreImpl = () => {
const [habits, setHabits] = useState<Habit[]>([]);
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useInventoryStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ const CATS_URL = "/api/inventory/item-categories";
const TAGS_URL = "/api/inventory/item-tags";

const generateId = () =>
(crypto as { randomUUID?: () => string }).randomUUID?.() ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`;
typeof globalThis.crypto?.randomUUID === "function"
? globalThis.crypto.randomUUID()
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;

const useInventoryImpl = () => {
const [items, setItems] = useState<InventoryItem[]>([]);
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useTaskStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ const API_URL = "/api/data";

const useTaskStoreImpl = () => {
const generateId = () =>
(crypto as { randomUUID?: () => string }).randomUUID?.() ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`;
typeof globalThis.crypto?.randomUUID === "function"
? globalThis.crypto.randomUUID()
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;
const sortNotes = (list: Note[]): Note[] => {
const pinned = list
.filter((n) => n.pinned)
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useWorklog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ const API_COMMUTES = "/api/commutes";
const API_ALL = "/api/all";

const generateId = () =>
(crypto as { randomUUID?: () => string }).randomUUID?.() ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`;
typeof globalThis.crypto?.randomUUID === "function"
? globalThis.crypto.randomUUID()
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;

const useWorklogImpl = () => {
const [trips, setTrips] = useState<Trip[]>([]);
Expand Down
7 changes: 3 additions & 4 deletions src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import type {

// ID generation utilities
export function generateId(): string {
return (
(crypto as { randomUUID?: () => string }).randomUUID?.() ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`
);
return typeof globalThis.crypto?.randomUUID === "function"
? globalThis.crypto.randomUUID()
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;
}

export function generateTimestamp(): number {
Expand Down
5 changes: 3 additions & 2 deletions src/stores/timers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { persist } from "zustand/middleware";
import { Timer } from "@/types";

const generateId = () =>
(crypto as { randomUUID?: () => string }).randomUUID?.() ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`;
typeof globalThis.crypto?.randomUUID === "function"
? globalThis.crypto.randomUUID()
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;

interface TimersState {
timers: Timer[];
Expand Down
Loading