mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 06:32:11 +00:00
useUser initialized from core
This commit is contained in:
parent
5f1f855ed4
commit
46e7e0c21a
1 changed files with 4 additions and 2 deletions
|
|
@ -2,8 +2,6 @@ const React = require('react');
|
|||
const { useServices } = require('stremio/services');
|
||||
const useModelState = require('stremio/common/useModelState');
|
||||
|
||||
const initUserState = () => null;
|
||||
|
||||
const mapUserState = (ctx) => {
|
||||
return ctx.content.auth ? ctx.content.auth.user : null;
|
||||
};
|
||||
|
|
@ -18,6 +16,10 @@ const useUser = () => {
|
|||
}
|
||||
});
|
||||
}, []);
|
||||
const initUserState = React.useCallback(() => {
|
||||
const ctx = core.getState('ctx');
|
||||
return mapUserState(ctx);
|
||||
}, []);
|
||||
const user = useModelState({
|
||||
model: 'ctx',
|
||||
map: mapUserState,
|
||||
|
|
|
|||
Loading…
Reference in a new issue