Files
mattermost-mobile/app/hooks/fetching_thread.ts
Anurag Shivarathri 724d72d98a [MM-47483] Activity Indicator while loading thread posts (#6865)
* Fix

* Addressing feedback

* Disabled pull to refresh when thread is being fetched

* Test fail fix

* Feedback changes
2022-12-17 01:15:22 +05:30

23 lines
688 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {useEffect, useState} from 'react';
import {of as of$} from 'rxjs';
import {distinctUntilChanged, switchMap} from 'rxjs/operators';
import {subject} from '@store/fetching_thread_store';
export const useFetchingThreadState = (rootId: string) => {
const [isFetching, setIsFetching] = useState(false);
useEffect(() => {
const sub = subject.pipe(
switchMap((s) => of$(s[rootId] || false)),
distinctUntilChanged(),
).subscribe(setIsFetching);
return () => sub.unsubscribe();
}, []);
return isFetching;
};