Federation view fixes (#923)

This commit is contained in:
KoalaSat 2023-11-01 12:18:00 +00:00 committed by Reckless_Satoshi
parent 48c551db83
commit 1fcd12dbab
7 changed files with 14 additions and 8 deletions

View File

@ -4,7 +4,7 @@
exclude: '(api|chat|control)/migrations/.*' exclude: '(api|chat|control)/migrations/.*'
repos: repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks' - repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v2.3.0 rev: v4.5.0
hooks: hooks:
- id: check-merge-conflict - id: check-merge-conflict
- id: check-yaml - id: check-yaml

View File

@ -60,7 +60,7 @@ const NavBar = (): JSX.Element => {
useEffect(() => { useEffect(() => {
// change tab (page) into the current route // change tab (page) into the current route
const pathPage: Page | string = location.pathname.split('/')[1]; const pathPage: Page | string = location.pathname.split('/')[1];
if (pathPage === 'index.html') { if (pathPage === 'index.html' || !pathPage) {
navigate('/robot'); navigate('/robot');
setPage('robot'); setPage('robot');
} }

View File

@ -3,7 +3,6 @@ import { Grid, Paper } from '@mui/material';
import SettingsForm from '../../components/SettingsForm'; import SettingsForm from '../../components/SettingsForm';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import FederationTable from '../../components/FederationTable'; import FederationTable from '../../components/FederationTable';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext';
const SettingsPage = (): JSX.Element => { const SettingsPage = (): JSX.Element => {
const { windowSize, navbarHeight, settings, setOpen, open, hostUrl } = const { windowSize, navbarHeight, settings, setOpen, open, hostUrl } =

View File

@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react'; import React, { useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { import {

View File

@ -30,7 +30,7 @@ const FederationTable = ({
fillContainer = false, fillContainer = false,
}: FederationTableProps): JSX.Element => { }: FederationTableProps): JSX.Element => {
const { t } = useTranslation(); const { t } = useTranslation();
const { federation, setFocusedCoordinator } = const { federation, setFocusedCoordinator, coordinatorUpdatedAt } =
useContext<UseFederationStoreType>(FederationContext); useContext<UseFederationStoreType>(FederationContext);
const { hostUrl } = useContext<UseAppStoreType>(AppContext); const { hostUrl } = useContext<UseAppStoreType>(AppContext);
const theme = useTheme(); const theme = useTheme();
@ -47,11 +47,12 @@ const FederationTable = ({
const height = defaultPageSize * verticalHeightRow + verticalHeightFrame; const height = defaultPageSize * verticalHeightRow + verticalHeightFrame;
const [useDefaultPageSize, setUseDefaultPageSize] = useState(true); const [useDefaultPageSize, setUseDefaultPageSize] = useState(true);
useEffect(() => { useEffect(() => {
if (useDefaultPageSize) { if (useDefaultPageSize) {
setPageSize(defaultPageSize); setPageSize(defaultPageSize);
} }
}); }, [coordinatorUpdatedAt]);
const localeText = { const localeText = {
MuiTablePagination: { labelRowsPerPage: t('Coordinators per page:') }, MuiTablePagination: { labelRowsPerPage: t('Coordinators per page:') },

View File

@ -227,8 +227,11 @@ export class Coordinator {
}); });
}; };
enable = () => { enable = (onEnabled: () => void = () => {}) => {
this.enabled = true; this.enabled = true;
this.update(() => {
onEnabled();
});
}; };
disable = () => { disable = () => {

View File

@ -117,10 +117,13 @@ export class Federation {
disableCoordinator = (shortAlias: string) => { disableCoordinator = (shortAlias: string) => {
this.coordinators[shortAlias].disable(); this.coordinators[shortAlias].disable();
this.triggerHook('onCoordinatorUpdate');
}; };
enableCoordinator = (shortAlias: string) => { enableCoordinator = (shortAlias: string) => {
this.coordinators[shortAlias].enable(); this.coordinators[shortAlias].enable(() => {
this.triggerHook('onCoordinatorUpdate');
});
}; };
} }