diff --git a/packages/status-react/src/protocol/provider.tsx b/packages/status-react/src/protocol/provider.tsx index bf21b313..ff1153f3 100644 --- a/packages/status-react/src/protocol/provider.tsx +++ b/packages/status-react/src/protocol/provider.tsx @@ -4,20 +4,13 @@ import { createClient } from '@status-im/js' import { Loading } from '../components/loading' -import type { - Account, - ActivityCenter, - Client, - ClientOptions, - Community, -} from '@status-im/js' +import type { Account, Client, ClientOptions, Community } from '@status-im/js' const Context = createContext(undefined) type State = { loading: boolean client: Client | undefined - activityCenter: ActivityCenter | undefined community: Community['description'] | undefined account: Account | undefined dispatch?: React.Dispatch @@ -42,7 +35,6 @@ const reducer = (state: State, action: Action): State => { ...state, loading: false, client, - activityCenter: client.activityCenter, community: client.community.description, } } @@ -64,7 +56,6 @@ export const ProtocolProvider = (props: Props) => { const [state, dispatch] = useReducer(reducer, { loading: true, client: undefined, - activityCenter: undefined, community: undefined, account: undefined, dispatch: undefined, @@ -112,7 +103,6 @@ export function useProtocol() { // we enforce initialization of client before rendering children return context as State & { client: Client - activityCenter: ActivityCenter community: Community['description'] dispatch: React.Dispatch } diff --git a/packages/status-react/src/protocol/use-activity-center.tsx b/packages/status-react/src/protocol/use-activity-center.tsx index 1a3fb0ae..d237db45 100644 --- a/packages/status-react/src/protocol/use-activity-center.tsx +++ b/packages/status-react/src/protocol/use-activity-center.tsx @@ -5,25 +5,23 @@ import { useProtocol } from './provider' import type { ActivityCenterLatest } from '@status-im/js' export const useActivityCenter = () => { - const { activityCenter } = useProtocol() + const { client } = useProtocol() const [latest, setData] = useState(() => - activityCenter.getLatest() + client.activityCenter.getLatest() ) useEffect(() => { - setData(activityCenter.getLatest()) + setData(client.activityCenter.getLatest()) const handleUpdate = (latest: ActivityCenterLatest) => { setData(latest) } - return activityCenter.onChange(handleUpdate) - // todo?: add latest.unreadChats and latest.notifications, will it render unnecessarily - }, [activityCenter]) + return client.activityCenter.onChange(handleUpdate) + }, [client.activityCenter]) return { - activityCenter, unreadChats: latest.unreadChats, } }