- Introduced an HTTP server to facilitate communication with the application. - Added route handlers for managing application configuration, including getting and updating settings. - Implemented notification operations with routes for retrieving, marking, and deleting notifications. - Created project and session management routes to list projects, sessions, and their details. - Developed SSH connection management routes for connecting, disconnecting, and retrieving SSH state and configuration. - Enhanced the application architecture to support real-time event streaming via Server-Sent Events (SSE). This commit significantly expands the application's capabilities by integrating an HTTP server and various management routes, improving user interaction and functionality.
36 lines
740 B
TypeScript
36 lines
740 B
TypeScript
import { useEffect, useState } from 'react';
|
|
|
|
import { api } from '@renderer/api';
|
|
|
|
/**
|
|
* Reads current zoom factor and stays subscribed to zoom updates from main.
|
|
*/
|
|
export function useZoomFactor(): number {
|
|
const [zoomFactor, setZoomFactor] = useState(1);
|
|
|
|
useEffect(() => {
|
|
let isMounted = true;
|
|
|
|
void api
|
|
.getZoomFactor()
|
|
.then((value) => {
|
|
if (isMounted) {
|
|
setZoomFactor(value);
|
|
}
|
|
})
|
|
.catch(() => {
|
|
// Keep default 1 if zoom factor cannot be read.
|
|
});
|
|
|
|
const unsubscribe = api.onZoomFactorChanged((value) => {
|
|
setZoomFactor(value);
|
|
});
|
|
|
|
return () => {
|
|
isMounted = false;
|
|
unsubscribe();
|
|
};
|
|
}, []);
|
|
|
|
return zoomFactor;
|
|
}
|