improve display, fix importing

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-09-29 13:26:09 +02:00
parent 2a67433f6e
commit 79c17473fe
4 changed files with 16 additions and 9 deletions

View File

@ -5,7 +5,7 @@ import { filterBadges, getTagDiff } from 'pl-fe/utils/badges';
import { deleteFromTimelines } from './timelines';
import type { Account, AdminGetAccountsParams, AdminGetReportsParams, PleromaConfig } from 'pl-api';
import type { Account, AdminGetAccountsParams, AdminGetReportsParams, PleromaConfig, Status } from 'pl-api';
import type { AppDispatch, RootState } from 'pl-fe/store';
const ADMIN_CONFIG_FETCH_REQUEST = 'ADMIN_CONFIG_FETCH_REQUEST' as const;
@ -109,13 +109,18 @@ const fetchReports = (params?: AdminGetReportsParams) =>
return getClient(state).admin.reports.getReports(params)
.then(({ items }) => {
const accounts: Array<Account> = [];
const statuses: Array<Status> = [];
items.forEach((report) => {
const accounts = [];
if (report.account?.account) accounts.push(report.account.account);
if (report.target_account?.account) accounts.push(report.target_account.account);
importEntities({ accounts, statuses: report.statuses });
statuses.push(...report.statuses as Array<Status>);
dispatch({ type: ADMIN_REPORTS_FETCH_SUCCESS, reports: items, params });
});
importEntities({ accounts, statuses });
}).catch(error => {
dispatch({ type: ADMIN_REPORTS_FETCH_FAIL, error, params });
});

View File

@ -185,7 +185,7 @@ const ScrollableList = React.forwardRef<Virtualizer<any, any>, IScrollableList &
position: 'relative',
}}
>
{!showLoading && data.length ? (
{(!showLoading || showPlaceholder) && data.length ? (
<>
{prepend}
{virtualItems.map((item) => (

View File

@ -129,8 +129,8 @@ const Notifications = () => {
const scrollContainer = (
<ScrollableList
isLoading={notificationsQuery.isLoading}
showLoading={notificationsQuery.isPending}
isLoading={notificationsQuery.isFetching}
showLoading={notificationsQuery.isLoading}
hasMore={notificationsQuery.hasNextPage}
emptyMessage={emptyMessage}
placeholderComponent={PlaceholderNotification}

View File

@ -15,7 +15,7 @@ import type {
Group as BaseGroup,
Poll as BasePoll,
Relationship as BaseRelationship,
StatusWithoutAccount as BaseStatus,
Status as BaseStatus,
} from 'pl-api';
import type { AppDispatch } from 'pl-fe/store';
@ -64,9 +64,11 @@ const importEntities = (entities: {
};
const processStatus = (status: BaseStatus) => {
if (!statuses[status.id] || status.account || !statuses[status.id].account) statuses[status.id] = status;
if (status.account) {
statuses[status.id] = status;
processAccount(status.account);
}
if (status.account) processAccount(status.account);
if (status.quote) processStatus(status.quote);
if (status.reblog) processStatus(status.reblog);
if (status.poll) polls[status.poll.id] = status.poll;