pl-fe: Remove some immutable usage

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-11-05 23:32:43 +01:00
parent f560896311
commit 563e5288fb
41 changed files with 482 additions and 463 deletions

View File

@ -15,8 +15,8 @@ const AdminTabs: React.FC = () => {
const intl = useIntl();
const match = useRouteMatch();
const approvalCount = useAppSelector(state => state.admin.awaitingApproval.count());
const reportsCount = useAppSelector(state => state.admin.openReports.count());
const approvalCount = useAppSelector(state => state.admin.awaitingApproval.length);
const reportsCount = useAppSelector(state => state.admin.openReports.length);
const tabs = [{
name: '/pl-fe/admin',

View File

@ -1,4 +1,3 @@
import { OrderedSet as ImmutableOrderedSet } from 'immutable';
import React, { useEffect, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { useHistory } from 'react-router-dom';
@ -22,9 +21,9 @@ const LatestAccountsPanel: React.FC<ILatestAccountsPanel> = ({ limit = 5 }) => {
const intl = useIntl();
const history = useHistory();
const dispatch = useAppDispatch();
const accountIds = useAppSelector<ImmutableOrderedSet<string>>((state) => state.admin.get('latestUsers').take(limit));
const accountIds = useAppSelector<Array<string>>((state) => state.admin.latestUsers.slice(0, limit));
const [total, setTotal] = useState<number | undefined>(accountIds.size);
const [total, setTotal] = useState<number | undefined>(accountIds.length);
useEffect(() => {
dispatch(fetchUsers({
@ -46,7 +45,7 @@ const LatestAccountsPanel: React.FC<ILatestAccountsPanel> = ({ limit = 5 }) => {
onActionClick={handleAction}
actionTitle={intl.formatMessage(messages.expand, { count: total })}
>
{accountIds.take(limit).map((account) => (
{accountIds.slice(0, limit).map((account) => (
<AccountContainer key={account} id={account} withRelationship={false} withDate />
))}
</Widget>

View File

@ -18,7 +18,7 @@ const UnapprovedAccount: React.FC<IUnapprovedAccount> = ({ accountId }) => {
const dispatch = useAppDispatch();
const { account } = useAccount(accountId);
const adminAccount = useAppSelector(state => state.admin.users.get(accountId));
const adminAccount = useAppSelector(state => state.admin.users[accountId]);
if (!account) return null;