From 13f58fcbffc808e339e4f9e24fa0a1af2ef6867f Mon Sep 17 00:00:00 2001 From: nklhrstv Date: Thu, 22 Oct 2020 17:59:46 +0300 Subject: [PATCH] useProfile code shorten --- src/common/useProfile.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/common/useProfile.js b/src/common/useProfile.js index ded6b9e64..4c9f8a9dc 100644 --- a/src/common/useProfile.js +++ b/src/common/useProfile.js @@ -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;