mirror of
https://github.com/zoriya/flood.git
synced 2025-12-06 07:16:18 +00:00
client: add page title speed display preference
This commit is contained in:
committed by
Jesse Chan
parent
c329c474a2
commit
5cb523d06a
@@ -3,15 +3,17 @@ import {observer} from 'mobx-react';
|
|||||||
import {useLingui} from '@lingui/react';
|
import {useLingui} from '@lingui/react';
|
||||||
|
|
||||||
import {compute, getTranslationString} from '../../util/size';
|
import {compute, getTranslationString} from '../../util/size';
|
||||||
|
import SettingStore from '../../stores/SettingStore';
|
||||||
import TransferDataStore from '../../stores/TransferDataStore';
|
import TransferDataStore from '../../stores/TransferDataStore';
|
||||||
|
|
||||||
const WindowTitle: FC = observer(() => {
|
const WindowTitle: FC = observer(() => {
|
||||||
|
const {UIPageTitleSpeedEnabled: enabled} = SettingStore.floodSettings;
|
||||||
const {transferSummary: summary} = TransferDataStore;
|
const {transferSummary: summary} = TransferDataStore;
|
||||||
const {i18n} = useLingui();
|
const {i18n} = useLingui();
|
||||||
|
|
||||||
let title = 'Flood';
|
let title = 'Flood';
|
||||||
|
|
||||||
if (summary != null && Object.keys(summary).length > 0) {
|
if (enabled && summary != null && Object.keys(summary).length > 0) {
|
||||||
const down = compute(summary.downRate);
|
const down = compute(summary.downRate);
|
||||||
const up = compute(summary.upRate);
|
const up = compute(summary.upRate);
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import type {Language} from '@client/constants/Languages';
|
|||||||
import type {FloodSettings} from '@shared/types/FloodSettings';
|
import type {FloodSettings} from '@shared/types/FloodSettings';
|
||||||
|
|
||||||
import ModalFormSectionHeader from '../ModalFormSectionHeader';
|
import ModalFormSectionHeader from '../ModalFormSectionHeader';
|
||||||
|
import MiscUISettingsList from './lists/MiscUISettingsList';
|
||||||
import TorrentContextMenuActionsList from './lists/TorrentContextMenuActionsList';
|
import TorrentContextMenuActionsList from './lists/TorrentContextMenuActionsList';
|
||||||
import TorrentListColumnsList from './lists/TorrentListColumnsList';
|
import TorrentListColumnsList from './lists/TorrentListColumnsList';
|
||||||
|
|
||||||
@@ -99,6 +100,12 @@ const UITab: FC<UITabProps> = ({onSettingsChange}: UITabProps) => {
|
|||||||
<FormRow>
|
<FormRow>
|
||||||
<TorrentContextMenuActionsList onSettingsChange={onSettingsChange} />
|
<TorrentContextMenuActionsList onSettingsChange={onSettingsChange} />
|
||||||
</FormRow>
|
</FormRow>
|
||||||
|
<ModalFormSectionHeader>
|
||||||
|
<Trans id="settings.ui.misc" />
|
||||||
|
</ModalFormSectionHeader>
|
||||||
|
<FormRow>
|
||||||
|
<MiscUISettingsList onSettingsChange={onSettingsChange} />
|
||||||
|
</FormRow>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import {FC, useRef} from 'react';
|
||||||
|
|
||||||
|
import SettingStore from '@client/stores/SettingStore';
|
||||||
|
import ToggleList from '@client/components/general/ToggleList';
|
||||||
|
|
||||||
|
import type {FloodSettings} from '@shared/types/FloodSettings';
|
||||||
|
|
||||||
|
interface MiscUISettingsListProps {
|
||||||
|
onSettingsChange: (changedSettings: Partial<FloodSettings>) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MiscUISettingsList: FC<MiscUISettingsListProps> = ({onSettingsChange}: MiscUISettingsListProps) => {
|
||||||
|
const changedUIPageTitleSpeedEnabledRef = useRef<FloodSettings['UIPageTitleSpeedEnabled']>(
|
||||||
|
SettingStore.floodSettings.UIPageTitleSpeedEnabled,
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ToggleList
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
label: 'settings.ui.page.title.speed',
|
||||||
|
defaultChecked: changedUIPageTitleSpeedEnabledRef.current,
|
||||||
|
onClick: () => {
|
||||||
|
changedUIPageTitleSpeedEnabledRef.current = !changedUIPageTitleSpeedEnabledRef.current;
|
||||||
|
onSettingsChange({UIPageTitleSpeedEnabled: changedUIPageTitleSpeedEnabledRef.current});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MiscUISettingsList;
|
||||||
@@ -210,6 +210,8 @@
|
|||||||
"settings.ui.displayed.context.menu.items": "Context Menu Items",
|
"settings.ui.displayed.context.menu.items": "Context Menu Items",
|
||||||
"settings.ui.displayed.details": "Torrent Detail Columns",
|
"settings.ui.displayed.details": "Torrent Detail Columns",
|
||||||
"settings.ui.language": "Language",
|
"settings.ui.language": "Language",
|
||||||
|
"settings.ui.misc": "Miscellaneous",
|
||||||
|
"settings.ui.page.title.speed": "Display upload and download speed in page title",
|
||||||
"settings.ui.locale": "Locale",
|
"settings.ui.locale": "Locale",
|
||||||
"settings.ui.tag.selector.mode": "Tag Selector Preference",
|
"settings.ui.tag.selector.mode": "Tag Selector Preference",
|
||||||
"settings.ui.tag.selector.mode.multi": "Multi Selection",
|
"settings.ui.tag.selector.mode.multi": "Multi Selection",
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ const defaultFloodSettings: Readonly<FloodSettings> = {
|
|||||||
mountPoints: [],
|
mountPoints: [],
|
||||||
deleteTorrentData: true,
|
deleteTorrentData: true,
|
||||||
startTorrentsOnLoad: true,
|
startTorrentsOnLoad: true,
|
||||||
|
UIPageTitleSpeedEnabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defaultFloodSettings;
|
export default defaultFloodSettings;
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ export interface FloodSettings {
|
|||||||
|
|
||||||
// Last used "Add Torrents" tab
|
// Last used "Add Torrents" tab
|
||||||
UITorrentsAddTab?: 'by-url' | 'by-file' | 'by-creation';
|
UITorrentsAddTab?: 'by-url' | 'by-file' | 'by-creation';
|
||||||
|
|
||||||
|
// Display upload and download speed in page title
|
||||||
|
UIPageTitleSpeedEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FloodSetting = keyof FloodSettings;
|
export type FloodSetting = keyof FloodSettings;
|
||||||
|
|||||||
Reference in New Issue
Block a user