Skip to content

Commit

Permalink
Merge pull request #2312 from matrix-org/dbkr/lowbw
Browse files Browse the repository at this point in the history
 Add 'low bandwidth setting'
  • Loading branch information
dbkr committed Nov 28, 2018
2 parents c3710a0 + 04c53c1 commit c45ee2e
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/Lifecycle.js
Expand Up @@ -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
Expand Down Expand Up @@ -477,7 +478,9 @@ async function startMatrixClient() {

Notifier.start();
UserActivity.start();
Presence.start();
if (!SettingsStore.getValue("lowBandwidth")) {
Presence.start();
}
DMRoomMap.makeShared().start();
ActiveWidgetStore.start();

Expand Down
2 changes: 1 addition & 1 deletion src/MatrixClientPeg.js
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions src/components/structures/TimelinePanel.js
Expand Up @@ -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();
Expand Down
9 changes: 8 additions & 1 deletion src/components/structures/UserSettings.js
Expand Up @@ -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
Expand Down Expand Up @@ -692,7 +699,7 @@ module.exports = React.createClass({
<div className="mx_UserSettings_toggle" key={setting.id}>
<SettingsFlag name={setting.id}
label={setting.label}
level={SettingLevel.ACCOUNT}
level={setting.level ? setting.level : SettingLevel.ACCOUNT}
onChange={setting.fn} />
</div>
);
Expand Down
11 changes: 8 additions & 3 deletions src/components/views/avatars/BaseAvatar.js
Expand Up @@ -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({
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/components/views/rooms/MessageComposerInput.js
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/settings/Settings.js
Expand Up @@ -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,
},
};

0 comments on commit c45ee2e

Please sign in to comment.