mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 20:38:55 +03:00
PreferencesUserSettingsTab: Add initial event indexing preferences.
This commit is contained in:
parent
2fe3603737
commit
c397de18bd
2 changed files with 100 additions and 0 deletions
|
@ -23,6 +23,8 @@ import SettingsStore from "../../../../../settings/SettingsStore";
|
||||||
import Field from "../../../elements/Field";
|
import Field from "../../../elements/Field";
|
||||||
import * as sdk from "../../../../..";
|
import * as sdk from "../../../../..";
|
||||||
import PlatformPeg from "../../../../../PlatformPeg";
|
import PlatformPeg from "../../../../../PlatformPeg";
|
||||||
|
import EventIndexPeg from "../../../../../indexing/EventIndexPeg";
|
||||||
|
import {formatBytes} from "../../../../../utils/FormattingUtils";
|
||||||
|
|
||||||
export default class PreferencesUserSettingsTab extends React.Component {
|
export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
static COMPOSER_SETTINGS = [
|
static COMPOSER_SETTINGS = [
|
||||||
|
@ -70,6 +72,13 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
alwaysShowMenuBarSupported: false,
|
alwaysShowMenuBarSupported: false,
|
||||||
minimizeToTray: true,
|
minimizeToTray: true,
|
||||||
minimizeToTraySupported: false,
|
minimizeToTraySupported: false,
|
||||||
|
eventIndexSize: 0,
|
||||||
|
crawlingRooms: 0,
|
||||||
|
totalCrawlingRooms: 0,
|
||||||
|
eventIndexingEnabled:
|
||||||
|
SettingsStore.getValueAt(SettingLevel.DEVICE, 'enableCrawling'),
|
||||||
|
crawlerSleepTime:
|
||||||
|
SettingsStore.getValueAt(SettingLevel.DEVICE, 'crawlerSleepTime'),
|
||||||
autocompleteDelay:
|
autocompleteDelay:
|
||||||
SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay').toString(10),
|
SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay').toString(10),
|
||||||
readMarkerInViewThresholdMs:
|
readMarkerInViewThresholdMs:
|
||||||
|
@ -100,6 +109,19 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
minimizeToTray = await platform.getMinimizeToTrayEnabled();
|
minimizeToTray = await platform.getMinimizeToTrayEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let eventIndexSize = 0;
|
||||||
|
let crawlingRooms = 0;
|
||||||
|
let totalCrawlingRooms = 0;
|
||||||
|
|
||||||
|
let eventIndex = EventIndexPeg.get();
|
||||||
|
|
||||||
|
if (eventIndex !== null) {
|
||||||
|
eventIndexSize = await eventIndex.indexSize();
|
||||||
|
let crawledRooms = eventIndex.currentlyCrawledRooms();
|
||||||
|
crawlingRooms = crawledRooms.crawlingRooms.size;
|
||||||
|
totalCrawlingRooms = crawledRooms.totalRooms.size;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
autoLaunch,
|
autoLaunch,
|
||||||
autoLaunchSupported,
|
autoLaunchSupported,
|
||||||
|
@ -107,6 +129,9 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
alwaysShowMenuBar,
|
alwaysShowMenuBar,
|
||||||
minimizeToTraySupported,
|
minimizeToTraySupported,
|
||||||
minimizeToTray,
|
minimizeToTray,
|
||||||
|
eventIndexSize,
|
||||||
|
crawlingRooms,
|
||||||
|
totalCrawlingRooms,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +162,20 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
SettingsStore.setValue("readMarkerOutOfViewThresholdMs", null, SettingLevel.DEVICE, e.target.value);
|
SettingsStore.setValue("readMarkerOutOfViewThresholdMs", null, SettingLevel.DEVICE, e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_onEventIndexingEnabledChange = (checked) => {
|
||||||
|
SettingsStore.setValue("enableCrawling", null, SettingLevel.DEVICE, checked);
|
||||||
|
|
||||||
|
if (checked) EventIndexPeg.start();
|
||||||
|
else EventIndexPeg.stop();
|
||||||
|
|
||||||
|
this.setState({eventIndexingEnabled: checked});
|
||||||
|
}
|
||||||
|
|
||||||
|
_onCrawlerSleepTimeChange = (e) => {
|
||||||
|
this.setState({crawlerSleepTime: e.target.value});
|
||||||
|
SettingsStore.setValue("crawlerSleepTime", null, SettingLevel.DEVICE, e.target.value);
|
||||||
|
}
|
||||||
|
|
||||||
_renderGroup(settingIds) {
|
_renderGroup(settingIds) {
|
||||||
const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag");
|
const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag");
|
||||||
return settingIds.map(i => <SettingsFlag key={i} name={i} level={SettingLevel.ACCOUNT} />);
|
return settingIds.map(i => <SettingsFlag key={i} name={i} level={SettingLevel.ACCOUNT} />);
|
||||||
|
@ -167,9 +206,61 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
label={_t('Show tray icon and minimize window to it on close')} />;
|
label={_t('Show tray icon and minimize window to it on close')} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let eventIndexingSettings = null;
|
||||||
|
let crawlerState;
|
||||||
|
|
||||||
|
if (!this.state.eventIndexingEnabled) {
|
||||||
|
crawlerState = <div>{_t("Message downloader is stopped.")}</div>;
|
||||||
|
}
|
||||||
|
else if (this.state.crawlingRooms === 0) {
|
||||||
|
crawlerState = <div>{_t("Message downloader is currently idle.")}</div>;
|
||||||
|
} else {
|
||||||
|
crawlerState = (
|
||||||
|
<div>{_t(
|
||||||
|
"Currently downloading mesages in %(crawlingRooms)s of %(totalRooms)s rooms.",
|
||||||
|
{ crawlingRooms: this.state.crawlingRooms,
|
||||||
|
totalRooms: this.state.totalCrawlingRooms,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EventIndexPeg.get() !== null) {
|
||||||
|
eventIndexingSettings = (
|
||||||
|
<div className="mx_SettingsTab_section">
|
||||||
|
<span className="mx_SettingsTab_subheading">{_t("Encrypted search")}</span>
|
||||||
|
{
|
||||||
|
_t( "To enable search in encrypted rooms, Riot needs to run " +
|
||||||
|
"a background process to download historical messages " +
|
||||||
|
"from those rooms to your computer."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
<div className='mx_SettingsTab_subsectionText'>
|
||||||
|
{_t("Message disk usage:")} {formatBytes(this.state.eventIndexSize, 0)}<br />
|
||||||
|
{crawlerState}<br />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<LabelledToggleSwitch
|
||||||
|
value={this.state.eventIndexingEnabled}
|
||||||
|
onChange={this._onEventIndexingEnabledChange}
|
||||||
|
label={_t('Enable message downloading')} />
|
||||||
|
|
||||||
|
<Field
|
||||||
|
id={"crawlerSleepTimeMs"}
|
||||||
|
label={_t('Message downloading sleep time(ms)')}
|
||||||
|
type='number'
|
||||||
|
value={this.state.crawlerSleepTime}
|
||||||
|
onChange={this._onCrawlerSleepTimeChange} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_SettingsTab mx_PreferencesUserSettingsTab">
|
<div className="mx_SettingsTab mx_PreferencesUserSettingsTab">
|
||||||
<div className="mx_SettingsTab_heading">{_t("Preferences")}</div>
|
<div className="mx_SettingsTab_heading">{_t("Preferences")}</div>
|
||||||
|
|
||||||
|
{eventIndexingSettings}
|
||||||
|
|
||||||
<div className="mx_SettingsTab_section">
|
<div className="mx_SettingsTab_section">
|
||||||
<span className="mx_SettingsTab_subheading">{_t("Composer")}</span>
|
<span className="mx_SettingsTab_subheading">{_t("Composer")}</span>
|
||||||
{this._renderGroup(PreferencesUserSettingsTab.COMPOSER_SETTINGS)}
|
{this._renderGroup(PreferencesUserSettingsTab.COMPOSER_SETTINGS)}
|
||||||
|
|
|
@ -415,6 +415,7 @@
|
||||||
"Allow fallback call assist server turn.matrix.org when your homeserver does not offer one (your IP address would be shared during a call)": "Allow fallback call assist server turn.matrix.org when your homeserver does not offer one (your IP address would be shared during a call)",
|
"Allow fallback call assist server turn.matrix.org when your homeserver does not offer one (your IP address would be shared during a call)": "Allow fallback call assist server turn.matrix.org when your homeserver does not offer one (your IP address would be shared during a call)",
|
||||||
"Send read receipts for messages (requires compatible homeserver to disable)": "Send read receipts for messages (requires compatible homeserver to disable)",
|
"Send read receipts for messages (requires compatible homeserver to disable)": "Send read receipts for messages (requires compatible homeserver to disable)",
|
||||||
"Show previews/thumbnails for images": "Show previews/thumbnails for images",
|
"Show previews/thumbnails for images": "Show previews/thumbnails for images",
|
||||||
|
"How long should the crawler wait between requests": "How long should the crawler wait between requests",
|
||||||
"Collecting app version information": "Collecting app version information",
|
"Collecting app version information": "Collecting app version information",
|
||||||
"Collecting logs": "Collecting logs",
|
"Collecting logs": "Collecting logs",
|
||||||
"Uploading report": "Uploading report",
|
"Uploading report": "Uploading report",
|
||||||
|
@ -731,6 +732,14 @@
|
||||||
"Start automatically after system login": "Start automatically after system login",
|
"Start automatically after system login": "Start automatically after system login",
|
||||||
"Always show the window menu bar": "Always show the window menu bar",
|
"Always show the window menu bar": "Always show the window menu bar",
|
||||||
"Show tray icon and minimize window to it on close": "Show tray icon and minimize window to it on close",
|
"Show tray icon and minimize window to it on close": "Show tray icon and minimize window to it on close",
|
||||||
|
"Message downloader is stopped.": "Message downloader is stopped.",
|
||||||
|
"Message downloader is currently idle.": "Message downloader is currently idle.",
|
||||||
|
"Currently downloading mesages in %(crawlingRooms)s of %(totalRooms)s rooms.": "Currently downloading mesages in %(crawlingRooms)s of %(totalRooms)s rooms.",
|
||||||
|
"Encrypted search": "Encrypted search",
|
||||||
|
"To enable search in encrypted rooms, Riot needs to run a background process to download historical messages from those rooms to your computer.": "To enable search in encrypted rooms, Riot needs to run a background process to download historical messages from those rooms to your computer.",
|
||||||
|
"Message disk usage:": "Message disk usage:",
|
||||||
|
"Enable message downloading": "Enable message downloading",
|
||||||
|
"Message downloading sleep time(ms)": "Message downloading sleep time(ms)",
|
||||||
"Preferences": "Preferences",
|
"Preferences": "Preferences",
|
||||||
"Composer": "Composer",
|
"Composer": "Composer",
|
||||||
"Timeline": "Timeline",
|
"Timeline": "Timeline",
|
||||||
|
|
Loading…
Reference in a new issue