mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
- Updated the development script to include a build step before launching the app. - Refactored the registration of quick ask and autocomplete functionalities to be asynchronous, ensuring proper initialization. - Introduced IPC channels for getting and setting keyboard shortcuts, allowing users to customize their experience. - Enhanced the platform module to support better interaction with the Electron API for clipboard operations. - Improved the user interface for managing keyboard shortcuts in the settings dialog, providing a more intuitive experience.
31 lines
790 B
TypeScript
31 lines
790 B
TypeScript
"use client";
|
|
|
|
import { createContext, useEffect, useState, type ReactNode } from "react";
|
|
|
|
export interface PlatformContextValue {
|
|
isDesktop: boolean;
|
|
isWeb: boolean;
|
|
electronAPI: ElectronAPI | null;
|
|
}
|
|
|
|
const SSR_VALUE: PlatformContextValue = {
|
|
isDesktop: false,
|
|
isWeb: false,
|
|
electronAPI: null,
|
|
};
|
|
|
|
export const PlatformContext = createContext<PlatformContextValue>(SSR_VALUE);
|
|
|
|
export function PlatformProvider({ children }: { children: ReactNode }) {
|
|
const [value, setValue] = useState<PlatformContextValue>(SSR_VALUE);
|
|
|
|
useEffect(() => {
|
|
const api = window.electronAPI ?? null;
|
|
const isDesktop = !!api;
|
|
setValue({ isDesktop, isWeb: !isDesktop, electronAPI: api });
|
|
}, []);
|
|
|
|
return (
|
|
<PlatformContext.Provider value={value}>{children}</PlatformContext.Provider>
|
|
);
|
|
}
|