diff --git a/src/Lifecycle.js b/src/Lifecycle.js index b0912c759e0..21882660f32 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -32,6 +32,7 @@ import Modal from './Modal'; import sdk from './index'; import ActiveWidgetStore from './stores/ActiveWidgetStore'; import PlatformPeg from "./PlatformPeg"; +import SettingsStore from "./settings/SettingsStore"; /** * Called at startup, to attempt to build a logged-in Matrix session. It tries @@ -477,7 +478,9 @@ async function startMatrixClient() { Notifier.start(); UserActivity.start(); - Presence.start(); + if (!SettingsStore.getValue("lowBandwidth")) { + Presence.start(); + } DMRoomMap.makeShared().start(); ActiveWidgetStore.start(); diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 9a77901d2e5..c8c7325b806 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -114,7 +114,7 @@ class MatrixClientPeg { // try to initialise e2e on the new client try { // check that we have a version of the js-sdk which includes initCrypto - if (this.matrixClient.initCrypto) { + if (!SettingsStore.getValue("lowBandwidth") && this.matrixClient.initCrypto) { await this.matrixClient.initCrypto(); } } catch (e) { diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 8f4a0189a78..9f9575ddd13 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -380,8 +380,10 @@ var TimelinePanel = React.createClass({ // the actual user activity and the time they stopped // being active, but let's see if this is actually // necessary. - this.sendReadReceipt(); - this.updateReadMarker(); + if (!SettingsStore.getValue("lowBandwidth")) { + this.sendReadReceipt(); + this.updateReadMarker(); + } break; case 'ignore_state_changed': this.forceUpdate(); diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index cdb880d2757..e6d595cc14b 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -86,6 +86,13 @@ const SIMPLE_SETTINGS = [ { id: "pinUnreadRooms" }, { id: "showDeveloperTools" }, { id: "mergeUsersByLocalpart" }, + { + id: "lowBandwidth", + fn: () => { + PlatformPeg.get().reload(); + }, + level: SettingLevel.DEVICE, + }, ]; // These settings must be defined in SettingsStore @@ -692,7 +699,7 @@ module.exports = React.createClass({
); diff --git a/src/components/views/avatars/BaseAvatar.js b/src/components/views/avatars/BaseAvatar.js index 47de7c9dc4a..7241e7cd4c1 100644 --- a/src/components/views/avatars/BaseAvatar.js +++ b/src/components/views/avatars/BaseAvatar.js @@ -20,6 +20,7 @@ import PropTypes from 'prop-types'; import { MatrixClient } from 'matrix-js-sdk'; import AvatarLogic from '../../../Avatar'; import sdk from '../../../index'; +import SettingsStore from "../../../settings/SettingsStore"; import AccessibleButton from '../elements/AccessibleButton'; module.exports = React.createClass({ @@ -104,9 +105,13 @@ module.exports = React.createClass({ // work out the full set of urls to try to load. This is formed like so: // imageUrls: [ props.url, props.urls, default image ] - const urls = props.urls || []; - if (props.url) { - urls.unshift(props.url); // put in urls[0] + let urls = []; + if (!SettingsStore.getValue("lowBandwidth")) { + urls = props.urls || []; + + if (props.url) { + urls.unshift(props.url); // put in urls[0] + } } let defaultImageUrl = null; diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index 0740667242c..09eec7c39cb 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -511,6 +511,7 @@ export default class MessageComposerInput extends React.Component { sendTyping(isTyping) { if (SettingsStore.getValue('dontSendTypingNotifications')) return; + if (SettingsStore.getValue('lowBandwidth')) return; MatrixClientPeg.get().sendTyping( this.props.room.roomId, this.isTyping, TYPING_SERVER_TIMEOUT, diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7bb48a4d121..2dfd7e53cfa 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -261,6 +261,7 @@ "Enable widget screenshots on supported widgets": "Enable widget screenshots on supported widgets", "Show empty room list headings": "Show empty room list headings", "Show developer tools": "Show developer tools", + "Low Bandwidth Mode": "Low Bandwidth Mode", "Collecting app version information": "Collecting app version information", "Collecting logs": "Collecting logs", "Uploading report": "Uploading report", diff --git a/src/settings/Settings.js b/src/settings/Settings.js index d666b6dabf2..c8b57ebb937 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -316,4 +316,9 @@ export const SETTINGS = { displayName: _td('Show developer tools'), default: false, }, + "lowBandwidth": { + supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG, + displayName: _td('Low Bandwidth Mode'), + default: false, + }, };