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 };
|
type FilterContext = { contextType?: string };
|
||||||
|
|
||||||
const getFilters = (state: RootState, query: FilterContext) =>
|
const getFilters = (state: Pick<RootState, 'filters'>, query: FilterContext) =>
|
||||||
state.filters.filter((filter) =>
|
state.filters.filter((filter) =>
|
||||||
(!query?.contextType || filter.context.includes(toServerSideType(query.contextType)))
|
(!query?.contextType || filter.context.includes(toServerSideType(query.contextType)))
|
||||||
&& (filter.expires_at === null || Date.parse(filter.expires_at) > new Date().getTime()),
|
&& (filter.expires_at === null || Date.parse(filter.expires_at) > new Date().getTime()),
|
||||||
@ -111,14 +111,13 @@ const makeGetStatus = () => createSelector(
|
|||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
(_state: RootState, { username }: APIStatus) => username,
|
(_state: RootState, { username }: APIStatus) => username,
|
||||||
getFilters,
|
(state: RootState) => state.filters,
|
||||||
|
(_state: RootState, { contextType }: FilterContext) => contextType,
|
||||||
(state: RootState) => state.me,
|
(state: RootState) => state.me,
|
||||||
(state: RootState) => state.auth.client.features,
|
(state: RootState) => state.auth.client.features,
|
||||||
],
|
],
|
||||||
|
|
||||||
(statusBase, statusReblog, statusQuote, statusGroup, username, filters, me, features) => {
|
(statusBase, statusReblog, statusQuote, statusGroup, username, filters, contextType, me, features) => {
|
||||||
// const locale = getLocale('en');
|
|
||||||
|
|
||||||
if (!statusBase) return null;
|
if (!statusBase) return null;
|
||||||
const { account } = statusBase;
|
const { account } = statusBase;
|
||||||
const accountUsername = account.acct;
|
const accountUsername = account.acct;
|
||||||
@ -128,6 +127,8 @@ const makeGetStatus = () => createSelector(
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filters = getFilters({ filters }, { contextType });
|
||||||
|
|
||||||
const filtered = features.filtersV2
|
const filtered = features.filtersV2
|
||||||
? statusBase.filtered
|
? statusBase.filtered
|
||||||
: features.filters && account.id !== me && checkFiltered(statusReblog?.search_index || statusBase.search_index || '', filters) || [];
|
: features.filters && account.id !== me && checkFiltered(statusReblog?.search_index || statusBase.search_index || '', filters) || [];
|
||||||
|
|||||||
Reference in New Issue
Block a user