Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hiding muted waves in real time #2754

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/providers/queries/postQueries/wavesQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const useWavesQuery = (host: string) => {
const queryClient = useQueryClient();

const cache = useAppSelector(state => state.cache);
const mutes = useAppSelector(state => state.account.currentAccount.mutes);
const cacheRef = useRef(cache);

const cachedVotes = cache.votesCollection
Expand All @@ -42,9 +43,9 @@ export const useWavesQuery = (host: string) => {
// query initialization
const wavesQueries = useQueries({
queries: activePermlinks.map((pagePermlink, index) => ({
queryKey: [QUERIES.WAVES.GET, host, index],
queryFn: () => _fetchWaves(pagePermlink),
initialData: [],
queryKey: [QUERIES.WAVES.GET, host, index],
queryFn: () => _fetchWaves(pagePermlink),
initialData: [],
})),
});

Expand Down Expand Up @@ -220,10 +221,11 @@ export const useWavesQuery = (host: string) => {



const _dataArrs = wavesQueries.map((query) => query.data);
const _data = unionBy(...wavesQueries.map((query) => query.data), 'url');
const _filteredData = useMemo(() =>{ console.log('filtering waves'); return _data.filter(post => mutes.indexOf(post?.author) < 0)}, [mutes, _data])

return {
data: unionBy(..._dataArrs, 'url'),
data: _filteredData,
isRefreshing,
isLoading: isLoading || wavesQueries.lastItem?.isLoading || wavesQueries.lastItem?.isFetching,
fetchNextPage: _fetchNextPage,
Expand Down