mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 07:32:02 +00:00
useProfile code shorten
This commit is contained in:
parent
09be8bce0d
commit
13f58fcbff
1 changed files with 4 additions and 11 deletions
|
|
@ -4,22 +4,15 @@ const React = require('react');
|
||||||
const { useServices } = require('stremio/services');
|
const { useServices } = require('stremio/services');
|
||||||
const useModelState = require('stremio/common/useModelState');
|
const useModelState = require('stremio/common/useModelState');
|
||||||
|
|
||||||
const mapProfileState = (ctx) => {
|
const map = (ctx) => ctx.profile;
|
||||||
return ctx.profile;
|
|
||||||
};
|
|
||||||
|
|
||||||
const useProfile = () => {
|
const useProfile = () => {
|
||||||
const { core } = useServices();
|
const { core } = useServices();
|
||||||
const initProfileState = React.useCallback(() => {
|
const init = React.useCallback(() => {
|
||||||
const ctx = core.transport.getState('ctx');
|
const ctx = core.transport.getState('ctx');
|
||||||
return mapProfileState(ctx);
|
return map(ctx);
|
||||||
}, []);
|
}, []);
|
||||||
const profile = useModelState({
|
return useModelState({ model: 'ctx', init, map });
|
||||||
model: 'ctx',
|
|
||||||
init: initProfileState,
|
|
||||||
map: mapProfileState
|
|
||||||
});
|
|
||||||
return profile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = useProfile;
|
module.exports = useProfile;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue