mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-05-03 21:19:06 +00:00
23 lines
601 B
JavaScript
23 lines
601 B
JavaScript
const React = require('react');
|
|
const { useServices } = require('stremio/services');
|
|
const useModelState = require('stremio/common/useModelState');
|
|
|
|
const mapProfileState = (ctx) => {
|
|
return ctx.profile;
|
|
};
|
|
|
|
const useProfile = () => {
|
|
const { core } = useServices();
|
|
const initProfileState = React.useCallback(() => {
|
|
const ctx = core.getState('ctx');
|
|
return mapProfileState(ctx);
|
|
}, []);
|
|
const profile = useModelState({
|
|
model: 'ctx',
|
|
init: initProfileState,
|
|
map: mapProfileState
|
|
});
|
|
return profile;
|
|
};
|
|
|
|
module.exports = useProfile;
|