Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'low bandwidth setting' #2312

Merged
merged 4 commits into from Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need to reload to apply the setting? It seems kinda weird to say someone is entering low bandwidth mode and start the whole app up again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, is a bit weird but I don't think you can turn crypto off once you've called initCrypto()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, right.

},
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,
},
};