pl-fe: reduce rerenders by a lot
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -46,7 +46,7 @@ const toServerSideType = (columnType: string): Filter['context'][0] => {
|
||||
|
||||
type FilterContext = { contextType?: string };
|
||||
|
||||
const getFilters = (state: RootState, query: FilterContext) =>
|
||||
const getFilters = (state: Pick<RootState, 'filters'>, query: FilterContext) =>
|
||||
state.filters.filter((filter) =>
|
||||
(!query?.contextType || filter.context.includes(toServerSideType(query.contextType)))
|
||||
&& (filter.expires_at === null || Date.parse(filter.expires_at) > new Date().getTime()),
|
||||
@ -111,14 +111,13 @@ const makeGetStatus = () => createSelector(
|
||||
return undefined;
|
||||
},
|
||||
(_state: RootState, { username }: APIStatus) => username,
|
||||
getFilters,
|
||||
(state: RootState) => state.filters,
|
||||
(_state: RootState, { contextType }: FilterContext) => contextType,
|
||||
(state: RootState) => state.me,
|
||||
(state: RootState) => state.auth.client.features,
|
||||
],
|
||||
|
||||
(statusBase, statusReblog, statusQuote, statusGroup, username, filters, me, features) => {
|
||||
// const locale = getLocale('en');
|
||||
|
||||
(statusBase, statusReblog, statusQuote, statusGroup, username, filters, contextType, me, features) => {
|
||||
if (!statusBase) return null;
|
||||
const { account } = statusBase;
|
||||
const accountUsername = account.acct;
|
||||
@ -128,6 +127,8 @@ const makeGetStatus = () => createSelector(
|
||||
return null;
|
||||
}
|
||||
|
||||
filters = getFilters({ filters }, { contextType });
|
||||
|
||||
const filtered = features.filtersV2
|
||||
? statusBase.filtered
|
||||
: features.filters && account.id !== me && checkFiltered(statusReblog?.search_index || statusBase.search_index || '', filters) || [];
|
||||
|
||||
Reference in New Issue
Block a user