mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +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 useModelState = require('stremio/common/useModelState');
|
||||
|
||||
const mapProfileState = (ctx) => {
|
||||
return ctx.profile;
|
||||
};
|
||||
const map = (ctx) => ctx.profile;
|
||||
|
||||
const useProfile = () => {
|
||||
const { core } = useServices();
|
||||
const initProfileState = React.useCallback(() => {
|
||||
const init = React.useCallback(() => {
|
||||
const ctx = core.transport.getState('ctx');
|
||||
return mapProfileState(ctx);
|
||||
return map(ctx);
|
||||
}, []);
|
||||
const profile = useModelState({
|
||||
model: 'ctx',
|
||||
init: initProfileState,
|
||||
map: mapProfileState
|
||||
});
|
||||
return profile;
|
||||
return useModelState({ model: 'ctx', init, map });
|
||||
};
|
||||
|
||||
module.exports = useProfile;
|
||||
|
|
|
|||
Loading…
Reference in a new issue