stremio-web/src/common/useSettings.ts
2026-05-05 04:22:59 +02:00

27 lines
727 B
TypeScript

// Copyright (C) 2017-2025 Smart code 203358507
import { useCallback } from 'react';
import useProfile from './useProfile';
import { useCore } from 'stremio/core';
const useSettings = (): [Settings, (settings: Settings) => void] => {
const core = useCore();
const profile = useProfile();
const updateSettings = useCallback((settings: Settings) => {
core.transport.dispatch({
action: 'Ctx',
args: {
action: 'UpdateSettings',
args: {
...profile.settings,
...settings
}
}
});
}, [profile]);
return [profile.settings, updateSettings];
};
export default useSettings;