Merge pull request #1171 from matrix-org/t3chguy/delintify
De-Lint 23 files
This commit is contained in:
commit
fb86534ba3
25 changed files with 253 additions and 307 deletions
|
@ -1,6 +1,5 @@
|
||||||
# autogenerated file: run scripts/generate-eslint-error-ignore-file to update.
|
# autogenerated file: run scripts/generate-eslint-error-ignore-file to update.
|
||||||
|
|
||||||
src/AddThreepid.js
|
|
||||||
src/async-components/views/dialogs/EncryptedEventDialog.js
|
src/async-components/views/dialogs/EncryptedEventDialog.js
|
||||||
src/autocomplete/AutocompleteProvider.js
|
src/autocomplete/AutocompleteProvider.js
|
||||||
src/autocomplete/Autocompleter.js
|
src/autocomplete/Autocompleter.js
|
||||||
|
@ -9,8 +8,6 @@ src/autocomplete/DuckDuckGoProvider.js
|
||||||
src/autocomplete/EmojiProvider.js
|
src/autocomplete/EmojiProvider.js
|
||||||
src/autocomplete/RoomProvider.js
|
src/autocomplete/RoomProvider.js
|
||||||
src/autocomplete/UserProvider.js
|
src/autocomplete/UserProvider.js
|
||||||
src/Avatar.js
|
|
||||||
src/BasePlatform.js
|
|
||||||
src/CallHandler.js
|
src/CallHandler.js
|
||||||
src/component-index.js
|
src/component-index.js
|
||||||
src/components/structures/ContextualMenu.js
|
src/components/structures/ContextualMenu.js
|
||||||
|
@ -96,7 +93,6 @@ src/components/views/rooms/MessageComposerInput.js
|
||||||
src/components/views/rooms/MessageComposerInputOld.js
|
src/components/views/rooms/MessageComposerInputOld.js
|
||||||
src/components/views/rooms/PresenceLabel.js
|
src/components/views/rooms/PresenceLabel.js
|
||||||
src/components/views/rooms/ReadReceiptMarker.js
|
src/components/views/rooms/ReadReceiptMarker.js
|
||||||
src/components/views/rooms/RoomHeader.js
|
|
||||||
src/components/views/rooms/RoomList.js
|
src/components/views/rooms/RoomList.js
|
||||||
src/components/views/rooms/RoomNameEditor.js
|
src/components/views/rooms/RoomNameEditor.js
|
||||||
src/components/views/rooms/RoomPreviewBar.js
|
src/components/views/rooms/RoomPreviewBar.js
|
||||||
|
@ -115,16 +111,7 @@ src/components/views/settings/ChangePassword.js
|
||||||
src/components/views/settings/DevicesPanel.js
|
src/components/views/settings/DevicesPanel.js
|
||||||
src/components/views/settings/DevicesPanelEntry.js
|
src/components/views/settings/DevicesPanelEntry.js
|
||||||
src/components/views/settings/EnableNotificationsButton.js
|
src/components/views/settings/EnableNotificationsButton.js
|
||||||
src/components/views/voip/CallView.js
|
|
||||||
src/components/views/voip/IncomingCallBox.js
|
|
||||||
src/components/views/voip/VideoFeed.js
|
|
||||||
src/components/views/voip/VideoView.js
|
|
||||||
src/ContentMessages.js
|
src/ContentMessages.js
|
||||||
src/createRoom.js
|
|
||||||
src/DateUtils.js
|
|
||||||
src/email.js
|
|
||||||
src/Entities.js
|
|
||||||
src/extend.js
|
|
||||||
src/HtmlUtils.js
|
src/HtmlUtils.js
|
||||||
src/ImageUtils.js
|
src/ImageUtils.js
|
||||||
src/Invite.js
|
src/Invite.js
|
||||||
|
@ -135,30 +122,20 @@ src/Markdown.js
|
||||||
src/MatrixClientPeg.js
|
src/MatrixClientPeg.js
|
||||||
src/Modal.js
|
src/Modal.js
|
||||||
src/Notifier.js
|
src/Notifier.js
|
||||||
src/ObjectUtils.js
|
|
||||||
src/PasswordReset.js
|
|
||||||
src/PlatformPeg.js
|
src/PlatformPeg.js
|
||||||
src/Presence.js
|
src/Presence.js
|
||||||
src/ratelimitedfunc.js
|
src/ratelimitedfunc.js
|
||||||
src/Resend.js
|
|
||||||
src/RichText.js
|
src/RichText.js
|
||||||
src/Roles.js
|
src/Roles.js
|
||||||
src/RoomListSorter.js
|
|
||||||
src/RoomNotifs.js
|
|
||||||
src/Rooms.js
|
src/Rooms.js
|
||||||
src/ScalarAuthClient.js
|
src/ScalarAuthClient.js
|
||||||
src/ScalarMessaging.js
|
src/ScalarMessaging.js
|
||||||
src/SdkConfig.js
|
|
||||||
src/Skinner.js
|
|
||||||
src/SlashCommands.js
|
|
||||||
src/stores/LifecycleStore.js
|
|
||||||
src/TabComplete.js
|
src/TabComplete.js
|
||||||
src/TabCompleteEntries.js
|
src/TabCompleteEntries.js
|
||||||
src/TextForEvent.js
|
src/TextForEvent.js
|
||||||
src/Tinter.js
|
src/Tinter.js
|
||||||
src/UiEffects.js
|
src/UiEffects.js
|
||||||
src/Unread.js
|
src/Unread.js
|
||||||
src/UserActivity.js
|
|
||||||
src/utils/DecryptFile.js
|
src/utils/DecryptFile.js
|
||||||
src/utils/DMRoomMap.js
|
src/utils/DMRoomMap.js
|
||||||
src/utils/FormattingUtils.js
|
src/utils/FormattingUtils.js
|
||||||
|
|
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var MatrixClientPeg = require("./MatrixClientPeg");
|
import MatrixClientPeg from './MatrixClientPeg';
|
||||||
import { _t } from './languageHandler';
|
import { _t } from './languageHandler';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +44,7 @@ class AddThreepid {
|
||||||
this.sessionId = res.sid;
|
this.sessionId = res.sid;
|
||||||
return res;
|
return res;
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err.errcode == 'M_THREEPID_IN_USE') {
|
if (err.errcode === 'M_THREEPID_IN_USE') {
|
||||||
err.message = _t('This email address is already in use');
|
err.message = _t('This email address is already in use');
|
||||||
} else if (err.httpStatus) {
|
} else if (err.httpStatus) {
|
||||||
err.message = err.message + ` (Status ${err.httpStatus})`;
|
err.message = err.message + ` (Status ${err.httpStatus})`;
|
||||||
|
@ -69,7 +69,7 @@ class AddThreepid {
|
||||||
this.sessionId = res.sid;
|
this.sessionId = res.sid;
|
||||||
return res;
|
return res;
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err.errcode == 'M_THREEPID_IN_USE') {
|
if (err.errcode === 'M_THREEPID_IN_USE') {
|
||||||
err.message = _t('This phone number is already in use');
|
err.message = _t('This phone number is already in use');
|
||||||
} else if (err.httpStatus) {
|
} else if (err.httpStatus) {
|
||||||
err.message = err.message + ` (Status ${err.httpStatus})`;
|
err.message = err.message + ` (Status ${err.httpStatus})`;
|
||||||
|
@ -85,16 +85,15 @@ class AddThreepid {
|
||||||
* the request failed.
|
* the request failed.
|
||||||
*/
|
*/
|
||||||
checkEmailLinkClicked() {
|
checkEmailLinkClicked() {
|
||||||
var identityServerDomain = MatrixClientPeg.get().idBaseUrl.split("://")[1];
|
const identityServerDomain = MatrixClientPeg.get().idBaseUrl.split("://")[1];
|
||||||
return MatrixClientPeg.get().addThreePid({
|
return MatrixClientPeg.get().addThreePid({
|
||||||
sid: this.sessionId,
|
sid: this.sessionId,
|
||||||
client_secret: this.clientSecret,
|
client_secret: this.clientSecret,
|
||||||
id_server: identityServerDomain
|
id_server: identityServerDomain,
|
||||||
}, this.bind).catch(function(err) {
|
}, this.bind).catch(function(err) {
|
||||||
if (err.httpStatus === 401) {
|
if (err.httpStatus === 401) {
|
||||||
err.message = _t('Failed to verify email address: make sure you clicked the link in the email');
|
err.message = _t('Failed to verify email address: make sure you clicked the link in the email');
|
||||||
}
|
} else if (err.httpStatus) {
|
||||||
else if (err.httpStatus) {
|
|
||||||
err.message += ` (Status ${err.httpStatus})`;
|
err.message += ` (Status ${err.httpStatus})`;
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -104,6 +103,7 @@ class AddThreepid {
|
||||||
/**
|
/**
|
||||||
* Takes a phone number verification code as entered by the user and validates
|
* Takes a phone number verification code as entered by the user and validates
|
||||||
* it with the ID server, then if successful, adds the phone number.
|
* it with the ID server, then if successful, adds the phone number.
|
||||||
|
* @param {string} token phone number verification code as entered by the user
|
||||||
* @return {Promise} Resolves if the phone number was added. Rejects with an object
|
* @return {Promise} Resolves if the phone number was added. Rejects with an object
|
||||||
* with a "message" property which contains a human-readable message detailing why
|
* with a "message" property which contains a human-readable message detailing why
|
||||||
* the request failed.
|
* the request failed.
|
||||||
|
@ -119,7 +119,7 @@ class AddThreepid {
|
||||||
return MatrixClientPeg.get().addThreePid({
|
return MatrixClientPeg.get().addThreePid({
|
||||||
sid: this.sessionId,
|
sid: this.sessionId,
|
||||||
client_secret: this.clientSecret,
|
client_secret: this.clientSecret,
|
||||||
id_server: identityServerDomain
|
id_server: identityServerDomain,
|
||||||
}, this.bind);
|
}, this.bind);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,18 +15,18 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
var ContentRepo = require("matrix-js-sdk").ContentRepo;
|
import {ContentRepo} from 'matrix-js-sdk';
|
||||||
var MatrixClientPeg = require('./MatrixClientPeg');
|
import MatrixClientPeg from './MatrixClientPeg';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
avatarUrlForMember: function(member, width, height, resizeMethod) {
|
avatarUrlForMember: function(member, width, height, resizeMethod) {
|
||||||
var url = member.getAvatarUrl(
|
let url = member.getAvatarUrl(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
Math.floor(width * window.devicePixelRatio),
|
Math.floor(width * window.devicePixelRatio),
|
||||||
Math.floor(height * window.devicePixelRatio),
|
Math.floor(height * window.devicePixelRatio),
|
||||||
resizeMethod,
|
resizeMethod,
|
||||||
false,
|
false,
|
||||||
false
|
false,
|
||||||
);
|
);
|
||||||
if (!url) {
|
if (!url) {
|
||||||
// member can be null here currently since on invites, the JS SDK
|
// member can be null here currently since on invites, the JS SDK
|
||||||
|
@ -38,11 +38,11 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
avatarUrlForUser: function(user, width, height, resizeMethod) {
|
avatarUrlForUser: function(user, width, height, resizeMethod) {
|
||||||
var url = ContentRepo.getHttpUriForMxc(
|
const url = ContentRepo.getHttpUriForMxc(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(), user.avatarUrl,
|
MatrixClientPeg.get().getHomeserverUrl(), user.avatarUrl,
|
||||||
Math.floor(width * window.devicePixelRatio),
|
Math.floor(width * window.devicePixelRatio),
|
||||||
Math.floor(height * window.devicePixelRatio),
|
Math.floor(height * window.devicePixelRatio),
|
||||||
resizeMethod
|
resizeMethod,
|
||||||
);
|
);
|
||||||
if (!url || url.length === 0) {
|
if (!url || url.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -51,11 +51,11 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
defaultAvatarUrlForString: function(s) {
|
defaultAvatarUrlForString: function(s) {
|
||||||
var images = ['76cfa6', '50e2c2', 'f4c371'];
|
const images = ['76cfa6', '50e2c2', 'f4c371'];
|
||||||
var total = 0;
|
let total = 0;
|
||||||
for (var i = 0; i < s.length; ++i) {
|
for (let i = 0; i < s.length; ++i) {
|
||||||
total += s.charCodeAt(i);
|
total += s.charCodeAt(i);
|
||||||
}
|
}
|
||||||
return 'img/' + images[total % images.length] + '.png';
|
return 'img/' + images[total % images.length] + '.png';
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,6 +57,7 @@ export default class BasePlatform {
|
||||||
/**
|
/**
|
||||||
* Returns true if the platform supports displaying
|
* Returns true if the platform supports displaying
|
||||||
* notifications, otherwise false.
|
* notifications, otherwise false.
|
||||||
|
* @returns {boolean} whether the platform supports displaying notifications
|
||||||
*/
|
*/
|
||||||
supportsNotifications(): boolean {
|
supportsNotifications(): boolean {
|
||||||
return false;
|
return false;
|
||||||
|
@ -65,6 +66,7 @@ export default class BasePlatform {
|
||||||
/**
|
/**
|
||||||
* Returns true if the application currently has permission
|
* Returns true if the application currently has permission
|
||||||
* to display notifications. Otherwise false.
|
* to display notifications. Otherwise false.
|
||||||
|
* @returns {boolean} whether the application has permission to display notifications
|
||||||
*/
|
*/
|
||||||
maySendNotifications(): boolean {
|
maySendNotifications(): boolean {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -61,17 +61,18 @@ function twelveHourTime(date) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
formatDate: function(date, showTwelveHour=false) {
|
formatDate: function(date, showTwelveHour=false) {
|
||||||
var now = new Date();
|
const now = new Date();
|
||||||
const days = getDaysArray();
|
const days = getDaysArray();
|
||||||
const months = getMonthsArray();
|
const months = getMonthsArray();
|
||||||
if (date.toDateString() === now.toDateString()) {
|
if (date.toDateString() === now.toDateString()) {
|
||||||
return this.formatTime(date);
|
return this.formatTime(date);
|
||||||
}
|
} else if (now.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) {
|
||||||
else if (now.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) {
|
|
||||||
// TODO: use standard date localize function provided in counterpart
|
// TODO: use standard date localize function provided in counterpart
|
||||||
return _t('%(weekDayName)s %(time)s', {weekDayName: days[date.getDay()], time: this.formatTime(date, showTwelveHour)});
|
return _t('%(weekDayName)s %(time)s', {
|
||||||
}
|
weekDayName: days[date.getDay()],
|
||||||
else if (now.getFullYear() === date.getFullYear()) {
|
time: this.formatTime(date, showTwelveHour),
|
||||||
|
});
|
||||||
|
} else if (now.getFullYear() === date.getFullYear()) {
|
||||||
// TODO: use standard date localize function provided in counterpart
|
// TODO: use standard date localize function provided in counterpart
|
||||||
return _t('%(weekDayName)s, %(monthName)s %(day)s %(time)s', {
|
return _t('%(weekDayName)s, %(monthName)s %(day)s %(time)s', {
|
||||||
weekDayName: days[date.getDay()],
|
weekDayName: days[date.getDay()],
|
||||||
|
|
|
@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var React = require('react');
|
import sdk from './index';
|
||||||
var sdk = require('./index');
|
|
||||||
|
|
||||||
function isMatch(query, name, uid) {
|
function isMatch(query, name, uid) {
|
||||||
query = query.toLowerCase();
|
query = query.toLowerCase();
|
||||||
|
@ -33,8 +32,8 @@ function isMatch(query, name, uid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// split spaces in name and try matching constituent parts
|
// split spaces in name and try matching constituent parts
|
||||||
var parts = name.split(" ");
|
const parts = name.split(" ");
|
||||||
for (var i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
if (parts[i].indexOf(query) === 0) {
|
if (parts[i].indexOf(query) === 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +66,7 @@ class Entity {
|
||||||
|
|
||||||
class MemberEntity extends Entity {
|
class MemberEntity extends Entity {
|
||||||
getJsx() {
|
getJsx() {
|
||||||
var MemberTile = sdk.getComponent("rooms.MemberTile");
|
const MemberTile = sdk.getComponent("rooms.MemberTile");
|
||||||
return (
|
return (
|
||||||
<MemberTile key={this.model.userId} member={this.model} />
|
<MemberTile key={this.model.userId} member={this.model} />
|
||||||
);
|
);
|
||||||
|
@ -84,6 +83,7 @@ class UserEntity extends Entity {
|
||||||
super(model);
|
super(model);
|
||||||
this.showInviteButton = Boolean(showInviteButton);
|
this.showInviteButton = Boolean(showInviteButton);
|
||||||
this.inviteFn = inviteFn;
|
this.inviteFn = inviteFn;
|
||||||
|
this.onClick = this.onClick.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick() {
|
onClick() {
|
||||||
|
@ -93,15 +93,15 @@ class UserEntity extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
getJsx() {
|
getJsx() {
|
||||||
var UserTile = sdk.getComponent("rooms.UserTile");
|
const UserTile = sdk.getComponent("rooms.UserTile");
|
||||||
return (
|
return (
|
||||||
<UserTile key={this.model.userId} user={this.model}
|
<UserTile key={this.model.userId} user={this.model}
|
||||||
showInviteButton={this.showInviteButton} onClick={this.onClick.bind(this)} />
|
showInviteButton={this.showInviteButton} onClick={this.onClick} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
matches(queryString) {
|
matches(queryString) {
|
||||||
var name = this.model.displayName || this.model.userId;
|
const name = this.model.displayName || this.model.userId;
|
||||||
return isMatch(queryString, name, this.model.userId);
|
return isMatch(queryString, name, this.model.userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class UserEntity extends Entity {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
newEntity: function(jsx, matchFn) {
|
newEntity: function(jsx, matchFn) {
|
||||||
var entity = new Entity();
|
const entity = new Entity();
|
||||||
entity.getJsx = function() {
|
entity.getJsx = function() {
|
||||||
return jsx;
|
return jsx;
|
||||||
};
|
};
|
||||||
|
@ -137,5 +137,5 @@ module.exports = {
|
||||||
return users.map(function(u) {
|
return users.map(function(u) {
|
||||||
return new UserEntity(u, showInviteButton, inviteFn);
|
return new UserEntity(u, showInviteButton, inviteFn);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,8 +23,8 @@ limitations under the License.
|
||||||
* { key: $KEY, val: $VALUE, place: "add|del" }
|
* { key: $KEY, val: $VALUE, place: "add|del" }
|
||||||
*/
|
*/
|
||||||
module.exports.getKeyValueArrayDiffs = function(before, after) {
|
module.exports.getKeyValueArrayDiffs = function(before, after) {
|
||||||
var results = [];
|
const results = [];
|
||||||
var delta = {};
|
const delta = {};
|
||||||
Object.keys(before).forEach(function(beforeKey) {
|
Object.keys(before).forEach(function(beforeKey) {
|
||||||
delta[beforeKey] = delta[beforeKey] || 0; // init to 0 initially
|
delta[beforeKey] = delta[beforeKey] || 0; // init to 0 initially
|
||||||
delta[beforeKey]--; // keys present in the past have -ve values
|
delta[beforeKey]--; // keys present in the past have -ve values
|
||||||
|
@ -46,9 +46,9 @@ module.exports.getKeyValueArrayDiffs = function(before, after) {
|
||||||
results.push({ place: "del", key: muxedKey, val: beforeVal });
|
results.push({ place: "del", key: muxedKey, val: beforeVal });
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 0: // A mix of added/removed keys
|
case 0: {// A mix of added/removed keys
|
||||||
// compare old & new vals
|
// compare old & new vals
|
||||||
var itemDelta = {};
|
const itemDelta = {};
|
||||||
before[muxedKey].forEach(function(beforeVal) {
|
before[muxedKey].forEach(function(beforeVal) {
|
||||||
itemDelta[beforeVal] = itemDelta[beforeVal] || 0;
|
itemDelta[beforeVal] = itemDelta[beforeVal] || 0;
|
||||||
itemDelta[beforeVal]--;
|
itemDelta[beforeVal]--;
|
||||||
|
@ -68,9 +68,9 @@ module.exports.getKeyValueArrayDiffs = function(before, after) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
console.error("Calculated key delta of " + delta[muxedKey] +
|
console.error("Calculated key delta of " + delta[muxedKey] + " - this should never happen!");
|
||||||
" - this should never happen!");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -79,8 +79,10 @@ module.exports.getKeyValueArrayDiffs = function(before, after) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shallow-compare two objects for equality: each key and value must be
|
* Shallow-compare two objects for equality: each key and value must be identical
|
||||||
* identical
|
* @param {Object} objA First object to compare against the second
|
||||||
|
* @param {Object} objB Second object to compare against the first
|
||||||
|
* @return {boolean} whether the two objects have same key=values
|
||||||
*/
|
*/
|
||||||
module.exports.shallowEqual = function(objA, objB) {
|
module.exports.shallowEqual = function(objA, objB) {
|
||||||
if (objA === objB) {
|
if (objA === objB) {
|
||||||
|
@ -92,15 +94,15 @@ module.exports.shallowEqual = function(objA, objB) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var keysA = Object.keys(objA);
|
const keysA = Object.keys(objA);
|
||||||
var keysB = Object.keys(objB);
|
const keysB = Object.keys(objB);
|
||||||
|
|
||||||
if (keysA.length !== keysB.length) {
|
if (keysA.length !== keysB.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < keysA.length; i++) {
|
for (let i = 0; i < keysA.length; i++) {
|
||||||
var key = keysA[i];
|
const key = keysA[i];
|
||||||
if (!objB.hasOwnProperty(key) || objA[key] !== objB[key]) {
|
if (!objB.hasOwnProperty(key) || objA[key] !== objB[key]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Matrix = require("matrix-js-sdk");
|
import * as Matrix from 'matrix-js-sdk';
|
||||||
import { _t } from './languageHandler';
|
import { _t } from './languageHandler';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,7 @@ class PasswordReset {
|
||||||
constructor(homeserverUrl, identityUrl) {
|
constructor(homeserverUrl, identityUrl) {
|
||||||
this.client = Matrix.createClient({
|
this.client = Matrix.createClient({
|
||||||
baseUrl: homeserverUrl,
|
baseUrl: homeserverUrl,
|
||||||
idBaseUrl: identityUrl
|
idBaseUrl: identityUrl,
|
||||||
});
|
});
|
||||||
this.clientSecret = this.client.generateClientSecret();
|
this.clientSecret = this.client.generateClientSecret();
|
||||||
this.identityServerDomain = identityUrl.split("://")[1];
|
this.identityServerDomain = identityUrl.split("://")[1];
|
||||||
|
@ -53,7 +53,7 @@ class PasswordReset {
|
||||||
this.sessionId = res.sid;
|
this.sessionId = res.sid;
|
||||||
return res;
|
return res;
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err.errcode == 'M_THREEPID_NOT_FOUND') {
|
if (err.errcode === 'M_THREEPID_NOT_FOUND') {
|
||||||
err.message = _t('This email address was not found');
|
err.message = _t('This email address was not found');
|
||||||
} else if (err.httpStatus) {
|
} else if (err.httpStatus) {
|
||||||
err.message = err.message + ` (Status ${err.httpStatus})`;
|
err.message = err.message + ` (Status ${err.httpStatus})`;
|
||||||
|
@ -75,16 +75,15 @@ class PasswordReset {
|
||||||
threepid_creds: {
|
threepid_creds: {
|
||||||
sid: this.sessionId,
|
sid: this.sessionId,
|
||||||
client_secret: this.clientSecret,
|
client_secret: this.clientSecret,
|
||||||
id_server: this.identityServerDomain
|
id_server: this.identityServerDomain,
|
||||||
}
|
},
|
||||||
}, this.password).catch(function(err) {
|
}, this.password).catch(function(err) {
|
||||||
if (err.httpStatus === 401) {
|
if (err.httpStatus === 401) {
|
||||||
err.message = _t('Failed to verify email address: make sure you clicked the link in the email');
|
err.message = _t('Failed to verify email address: make sure you clicked the link in the email');
|
||||||
}
|
} else if (err.httpStatus === 404) {
|
||||||
else if (err.httpStatus === 404) {
|
err.message =
|
||||||
err.message = _t('Your email address does not appear to be associated with a Matrix ID on this Homeserver.');
|
_t('Your email address does not appear to be associated with a Matrix ID on this Homeserver.');
|
||||||
}
|
} else if (err.httpStatus) {
|
||||||
else if (err.httpStatus) {
|
|
||||||
err.message += ` (Status ${err.httpStatus})`;
|
err.message += ` (Status ${err.httpStatus})`;
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
|
|
|
@ -14,10 +14,8 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var MatrixClientPeg = require('./MatrixClientPeg');
|
import MatrixClientPeg from './MatrixClientPeg';
|
||||||
var dis = require('./dispatcher');
|
import dis from './dispatcher';
|
||||||
var sdk = require('./index');
|
|
||||||
var Modal = require('./Modal');
|
|
||||||
import { EventStatus } from 'matrix-js-sdk';
|
import { EventStatus } from 'matrix-js-sdk';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -37,12 +35,10 @@ module.exports = {
|
||||||
},
|
},
|
||||||
resend: function(event) {
|
resend: function(event) {
|
||||||
const room = MatrixClientPeg.get().getRoom(event.getRoomId());
|
const room = MatrixClientPeg.get().getRoom(event.getRoomId());
|
||||||
MatrixClientPeg.get().resendEvent(
|
MatrixClientPeg.get().resendEvent(event, room).done(function(res) {
|
||||||
event, room
|
|
||||||
).done(function(res) {
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'message_sent',
|
action: 'message_sent',
|
||||||
event: event
|
event: event,
|
||||||
});
|
});
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
// XXX: temporary logging to try to diagnose
|
// XXX: temporary logging to try to diagnose
|
||||||
|
@ -58,7 +54,7 @@ module.exports = {
|
||||||
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'message_send_failed',
|
action: 'message_send_failed',
|
||||||
event: event
|
event: event,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -66,7 +62,7 @@ module.exports = {
|
||||||
MatrixClientPeg.get().cancelPendingEvent(event);
|
MatrixClientPeg.get().cancelPendingEvent(event);
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'message_send_cancelled',
|
action: 'message_send_cancelled',
|
||||||
event: event
|
event: event,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ export function levelRoleMap() {
|
||||||
return {
|
return {
|
||||||
undefined: _t('Default'),
|
undefined: _t('Default'),
|
||||||
0: _t('User'),
|
0: _t('User'),
|
||||||
50: _t('Moderator'),
|
50: _t('Moderator'),
|
||||||
100: _t('Admin'),
|
100: _t('Admin'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,7 @@ limitations under the License.
|
||||||
function tsOfNewestEvent(room) {
|
function tsOfNewestEvent(room) {
|
||||||
if (room.timeline.length) {
|
if (room.timeline.length) {
|
||||||
return room.timeline[room.timeline.length - 1].getTs();
|
return room.timeline[room.timeline.length - 1].getTs();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return Number.MAX_SAFE_INTEGER;
|
return Number.MAX_SAFE_INTEGER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,5 +31,5 @@ function mostRecentActivityFirst(roomList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mostRecentActivityFirst: mostRecentActivityFirst
|
mostRecentActivityFirst,
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,7 +52,7 @@ export function getRoomNotifsState(roomId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setRoomNotifsState(roomId, newState) {
|
export function setRoomNotifsState(roomId, newState) {
|
||||||
if (newState == MUTE) {
|
if (newState === MUTE) {
|
||||||
return setRoomNotifsStateMuted(roomId);
|
return setRoomNotifsStateMuted(roomId);
|
||||||
} else {
|
} else {
|
||||||
return setRoomNotifsStateUnmuted(roomId, newState);
|
return setRoomNotifsStateUnmuted(roomId, newState);
|
||||||
|
@ -80,11 +80,11 @@ function setRoomNotifsStateMuted(roomId) {
|
||||||
kind: 'event_match',
|
kind: 'event_match',
|
||||||
key: 'room_id',
|
key: 'room_id',
|
||||||
pattern: roomId,
|
pattern: roomId,
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
actions: [
|
actions: [
|
||||||
'dont_notify',
|
'dont_notify',
|
||||||
]
|
],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return q.all(promises);
|
return q.all(promises);
|
||||||
|
@ -99,16 +99,16 @@ function setRoomNotifsStateUnmuted(roomId, newState) {
|
||||||
promises.push(cli.deletePushRule('global', 'override', overrideMuteRule.rule_id));
|
promises.push(cli.deletePushRule('global', 'override', overrideMuteRule.rule_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newState == 'all_messages') {
|
if (newState === 'all_messages') {
|
||||||
const roomRule = cli.getRoomPushRule('global', roomId);
|
const roomRule = cli.getRoomPushRule('global', roomId);
|
||||||
if (roomRule) {
|
if (roomRule) {
|
||||||
promises.push(cli.deletePushRule('global', 'room', roomRule.rule_id));
|
promises.push(cli.deletePushRule('global', 'room', roomRule.rule_id));
|
||||||
}
|
}
|
||||||
} else if (newState == 'mentions_only') {
|
} else if (newState === 'mentions_only') {
|
||||||
promises.push(cli.addPushRule('global', 'room', roomId, {
|
promises.push(cli.addPushRule('global', 'room', roomId, {
|
||||||
actions: [
|
actions: [
|
||||||
'dont_notify',
|
'dont_notify',
|
||||||
]
|
],
|
||||||
}));
|
}));
|
||||||
// https://matrix.org/jira/browse/SPEC-400
|
// https://matrix.org/jira/browse/SPEC-400
|
||||||
promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true));
|
promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true));
|
||||||
|
@ -119,8 +119,8 @@ function setRoomNotifsStateUnmuted(roomId, newState) {
|
||||||
{
|
{
|
||||||
set_tweak: 'sound',
|
set_tweak: 'sound',
|
||||||
value: 'default',
|
value: 'default',
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}));
|
}));
|
||||||
// https://matrix.org/jira/browse/SPEC-400
|
// https://matrix.org/jira/browse/SPEC-400
|
||||||
promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true));
|
promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true));
|
||||||
|
@ -145,20 +145,10 @@ function isRuleForRoom(roomId, rule) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const cond = rule.conditions[0];
|
const cond = rule.conditions[0];
|
||||||
if (
|
return (cond.kind === 'event_match' && cond.key === 'room_id' && cond.pattern === roomId);
|
||||||
cond.kind == 'event_match' &&
|
|
||||||
cond.key == 'room_id' &&
|
|
||||||
cond.pattern == roomId
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMuteRule(rule) {
|
function isMuteRule(rule) {
|
||||||
return (
|
return (rule.actions.length === 1 && rule.actions[0] === 'dont_notify');
|
||||||
rule.actions.length == 1 &&
|
|
||||||
rule.actions[0] == 'dont_notify'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var DEFAULTS = {
|
const DEFAULTS = {
|
||||||
// URL to a page we show in an iframe to configure integrations
|
// URL to a page we show in an iframe to configure integrations
|
||||||
integrations_ui_url: "https://scalar.vector.im/",
|
integrations_ui_url: "https://scalar.vector.im/",
|
||||||
// Base URL to the REST interface of the integrations server
|
// Base URL to the REST interface of the integrations server
|
||||||
|
@ -30,8 +30,8 @@ class SdkConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
static put(cfg) {
|
static put(cfg) {
|
||||||
var defaultKeys = Object.keys(DEFAULTS);
|
const defaultKeys = Object.keys(DEFAULTS);
|
||||||
for (var i = 0; i < defaultKeys.length; ++i) {
|
for (let i = 0; i < defaultKeys.length; ++i) {
|
||||||
if (cfg[defaultKeys[i]] === undefined) {
|
if (cfg[defaultKeys[i]] === undefined) {
|
||||||
cfg[defaultKeys[i]] = DEFAULTS[defaultKeys[i]];
|
cfg[defaultKeys[i]] = DEFAULTS[defaultKeys[i]];
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,19 +51,18 @@ class Skinner {
|
||||||
if (this.components !== null) {
|
if (this.components !== null) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Attempted to load a skin while a skin is already loaded"+
|
"Attempted to load a skin while a skin is already loaded"+
|
||||||
"If you want to change the active skin, call resetSkin first"
|
"If you want to change the active skin, call resetSkin first");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
this.components = {};
|
this.components = {};
|
||||||
var compKeys = Object.keys(skinObject.components);
|
const compKeys = Object.keys(skinObject.components);
|
||||||
for (var i = 0; i < compKeys.length; ++i) {
|
for (let i = 0; i < compKeys.length; ++i) {
|
||||||
var comp = skinObject.components[compKeys[i]];
|
const comp = skinObject.components[compKeys[i]];
|
||||||
this.addComponent(compKeys[i], comp);
|
this.addComponent(compKeys[i], comp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addComponent(name, comp) {
|
addComponent(name, comp) {
|
||||||
var slot = name;
|
let slot = name;
|
||||||
if (comp.replaces !== undefined) {
|
if (comp.replaces !== undefined) {
|
||||||
if (comp.replaces.indexOf('.') > -1) {
|
if (comp.replaces.indexOf('.') > -1) {
|
||||||
slot = comp.replaces;
|
slot = comp.replaces;
|
||||||
|
|
|
@ -186,7 +186,7 @@ const commands = {
|
||||||
if (targetRoomId) { break; }
|
if (targetRoomId) { break; }
|
||||||
}
|
}
|
||||||
if (!targetRoomId) {
|
if (!targetRoomId) {
|
||||||
return reject(_t("Unrecognised room alias:") + ' ' + roomAlias);
|
return reject(_t("Unrecognised room alias:") + ' ' + roomAlias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,8 +344,7 @@ const commands = {
|
||||||
_t('WARNING: KEY VERIFICATION FAILED! The signing key for %(userId)s and device' +
|
_t('WARNING: KEY VERIFICATION FAILED! The signing key for %(userId)s and device' +
|
||||||
' %(deviceId)s is "%(fprint)s" which does not match the provided key' +
|
' %(deviceId)s is "%(fprint)s" which does not match the provided key' +
|
||||||
' "%(fingerprint)s". This could mean your communications are being intercepted!',
|
' "%(fingerprint)s". This could mean your communications are being intercepted!',
|
||||||
{deviceId: deviceId, fprint: fprint, userId: userId, fingerprint: fingerprint})
|
{deviceId: deviceId, fprint: fprint, userId: userId, fingerprint: fingerprint}));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var dis = require("./dispatcher");
|
import dis from './dispatcher';
|
||||||
|
|
||||||
var MIN_DISPATCH_INTERVAL_MS = 500;
|
const MIN_DISPATCH_INTERVAL_MS = 500;
|
||||||
var CURRENTLY_ACTIVE_THRESHOLD_MS = 2000;
|
const CURRENTLY_ACTIVE_THRESHOLD_MS = 2000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class watches for user activity (moving the mouse or pressing a key)
|
* This class watches for user activity (moving the mouse or pressing a key)
|
||||||
|
@ -58,16 +58,15 @@ class UserActivity {
|
||||||
/**
|
/**
|
||||||
* Return true if there has been user activity very recently
|
* Return true if there has been user activity very recently
|
||||||
* (ie. within a few seconds)
|
* (ie. within a few seconds)
|
||||||
|
* @returns {boolean} true if user is currently/very recently active
|
||||||
*/
|
*/
|
||||||
userCurrentlyActive() {
|
userCurrentlyActive() {
|
||||||
return this.lastActivityAtTs > new Date().getTime() - CURRENTLY_ACTIVE_THRESHOLD_MS;
|
return this.lastActivityAtTs > new Date().getTime() - CURRENTLY_ACTIVE_THRESHOLD_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onUserActivity(event) {
|
_onUserActivity(event) {
|
||||||
if (event.screenX && event.type == "mousemove") {
|
if (event.screenX && event.type === "mousemove") {
|
||||||
if (event.screenX === this.lastScreenX &&
|
if (event.screenX === this.lastScreenX && event.screenY === this.lastScreenY) {
|
||||||
event.screenY === this.lastScreenY)
|
|
||||||
{
|
|
||||||
// mouse hasn't actually moved
|
// mouse hasn't actually moved
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -79,28 +78,24 @@ class UserActivity {
|
||||||
if (this.lastDispatchAtTs < this.lastActivityAtTs - MIN_DISPATCH_INTERVAL_MS) {
|
if (this.lastDispatchAtTs < this.lastActivityAtTs - MIN_DISPATCH_INTERVAL_MS) {
|
||||||
this.lastDispatchAtTs = this.lastActivityAtTs;
|
this.lastDispatchAtTs = this.lastActivityAtTs;
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'user_activity'
|
action: 'user_activity',
|
||||||
});
|
});
|
||||||
if (!this.activityEndTimer) {
|
if (!this.activityEndTimer) {
|
||||||
this.activityEndTimer = setTimeout(
|
this.activityEndTimer = setTimeout(this._onActivityEndTimer.bind(this), MIN_DISPATCH_INTERVAL_MS);
|
||||||
this._onActivityEndTimer.bind(this), MIN_DISPATCH_INTERVAL_MS
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onActivityEndTimer() {
|
_onActivityEndTimer() {
|
||||||
var now = new Date().getTime();
|
const now = new Date().getTime();
|
||||||
var targetTime = this.lastActivityAtTs + MIN_DISPATCH_INTERVAL_MS;
|
const targetTime = this.lastActivityAtTs + MIN_DISPATCH_INTERVAL_MS;
|
||||||
if (now >= targetTime) {
|
if (now >= targetTime) {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'user_activity_end'
|
action: 'user_activity_end',
|
||||||
});
|
});
|
||||||
this.activityEndTimer = undefined;
|
this.activityEndTimer = undefined;
|
||||||
} else {
|
} else {
|
||||||
this.activityEndTimer = setTimeout(
|
this.activityEndTimer = setTimeout(this._onActivityEndTimer.bind(this), targetTime - now);
|
||||||
this._onActivityEndTimer.bind(this), targetTime - now
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,18 +16,18 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var React = require('react');
|
import React from 'react';
|
||||||
var classNames = require('classnames');
|
import classNames from 'classnames';
|
||||||
var sdk = require('../../../index');
|
import sdk from '../../../index';
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
var MatrixClientPeg = require('../../../MatrixClientPeg');
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
var Modal = require("../../../Modal");
|
import Modal from "../../../Modal";
|
||||||
var dis = require("../../../dispatcher");
|
import dis from "../../../dispatcher";
|
||||||
var rate_limited_func = require('../../../ratelimitedfunc');
|
import RateLimitedFunc from '../../../ratelimitedfunc';
|
||||||
|
|
||||||
var linkify = require('linkifyjs');
|
import * as linkify from 'linkifyjs';
|
||||||
var linkifyElement = require('linkifyjs/element');
|
import linkifyElement from 'linkifyjs/element';
|
||||||
var linkifyMatrix = require('../../../linkify-matrix');
|
import linkifyMatrix from '../../../linkify-matrix';
|
||||||
import AccessibleButton from '../elements/AccessibleButton';
|
import AccessibleButton from '../elements/AccessibleButton';
|
||||||
import {CancelButton} from './SimpleRoomHeader';
|
import {CancelButton} from './SimpleRoomHeader';
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
var cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
cli.on("RoomState.events", this._onRoomStateEvents);
|
cli.on("RoomState.events", this._onRoomStateEvents);
|
||||||
|
|
||||||
// When a room name occurs, RoomState.events is fired *before*
|
// When a room name occurs, RoomState.events is fired *before*
|
||||||
|
@ -79,14 +79,14 @@ module.exports = React.createClass({
|
||||||
if (this.props.room) {
|
if (this.props.room) {
|
||||||
this.props.room.removeListener("Room.name", this._onRoomNameChange);
|
this.props.room.removeListener("Room.name", this._onRoomNameChange);
|
||||||
}
|
}
|
||||||
var cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
if (cli) {
|
if (cli) {
|
||||||
cli.removeListener("RoomState.events", this._onRoomStateEvents);
|
cli.removeListener("RoomState.events", this._onRoomStateEvents);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_onRoomStateEvents: function(event, state) {
|
_onRoomStateEvents: function(event, state) {
|
||||||
if (!this.props.room || event.getRoomId() != this.props.room.roomId) {
|
if (!this.props.room || event.getRoomId() !== this.props.room.roomId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,8 @@ module.exports = React.createClass({
|
||||||
this._rateLimitedUpdate();
|
this._rateLimitedUpdate();
|
||||||
},
|
},
|
||||||
|
|
||||||
_rateLimitedUpdate: new rate_limited_func(function() {
|
_rateLimitedUpdate: new RateLimitedFunc(function() {
|
||||||
|
/* eslint-disable babel/no-invalid-this */
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}, 500),
|
}, 500),
|
||||||
|
|
||||||
|
@ -109,15 +110,14 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onAvatarSelected: function(ev) {
|
onAvatarSelected: function(ev) {
|
||||||
var self = this;
|
const changeAvatar = this.refs.changeAvatar;
|
||||||
var changeAvatar = this.refs.changeAvatar;
|
|
||||||
if (!changeAvatar) {
|
if (!changeAvatar) {
|
||||||
console.error("No ChangeAvatar found to upload image to!");
|
console.error("No ChangeAvatar found to upload image to!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
changeAvatar.onFileSelected(ev).catch(function(err) {
|
changeAvatar.onFileSelected(ev).catch(function(err) {
|
||||||
var errMsg = (typeof err === "string") ? err : (err.error || "");
|
const errMsg = (typeof err === "string") ? err : (err.error || "");
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
console.error("Failed to set avatar: " + errMsg);
|
console.error("Failed to set avatar: " + errMsg);
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: _t("Error"),
|
title: _t("Error"),
|
||||||
|
@ -133,10 +133,10 @@ module.exports = React.createClass({
|
||||||
/**
|
/**
|
||||||
* After editing the settings, get the new name for the room
|
* After editing the settings, get the new name for the room
|
||||||
*
|
*
|
||||||
* Returns undefined if we didn't let the user edit the room name
|
* @return {?string} newName or undefined if we didn't let the user edit the room name
|
||||||
*/
|
*/
|
||||||
getEditedName: function() {
|
getEditedName: function() {
|
||||||
var newName;
|
let newName;
|
||||||
if (this.refs.nameEditor) {
|
if (this.refs.nameEditor) {
|
||||||
newName = this.refs.nameEditor.getRoomName();
|
newName = this.refs.nameEditor.getRoomName();
|
||||||
}
|
}
|
||||||
|
@ -146,10 +146,10 @@ module.exports = React.createClass({
|
||||||
/**
|
/**
|
||||||
* After editing the settings, get the new topic for the room
|
* After editing the settings, get the new topic for the room
|
||||||
*
|
*
|
||||||
* Returns undefined if we didn't let the user edit the room topic
|
* @return {?string} newTopic or undefined if we didn't let the user edit the room topic
|
||||||
*/
|
*/
|
||||||
getEditedTopic: function() {
|
getEditedTopic: function() {
|
||||||
var newTopic;
|
let newTopic;
|
||||||
if (this.refs.topicEditor) {
|
if (this.refs.topicEditor) {
|
||||||
newTopic = this.refs.topicEditor.getTopic();
|
newTopic = this.refs.topicEditor.getTopic();
|
||||||
}
|
}
|
||||||
|
@ -157,38 +157,31 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var RoomAvatar = sdk.getComponent("avatars.RoomAvatar");
|
const RoomAvatar = sdk.getComponent("avatars.RoomAvatar");
|
||||||
var ChangeAvatar = sdk.getComponent("settings.ChangeAvatar");
|
const ChangeAvatar = sdk.getComponent("settings.ChangeAvatar");
|
||||||
var TintableSvg = sdk.getComponent("elements.TintableSvg");
|
const TintableSvg = sdk.getComponent("elements.TintableSvg");
|
||||||
const EmojiText = sdk.getComponent('elements.EmojiText');
|
const EmojiText = sdk.getComponent('elements.EmojiText');
|
||||||
|
|
||||||
var header;
|
let name = null;
|
||||||
var name = null;
|
let searchStatus = null;
|
||||||
var searchStatus = null;
|
let topicElement = null;
|
||||||
var topic_el = null;
|
let cancelButton = null;
|
||||||
var cancel_button = null;
|
let spinner = null;
|
||||||
var spinner = null;
|
let saveButton = null;
|
||||||
var save_button = null;
|
let settingsButton = null;
|
||||||
var settings_button = null;
|
|
||||||
|
let canSetRoomName;
|
||||||
|
let canSetRoomAvatar;
|
||||||
|
let canSetRoomTopic;
|
||||||
if (this.props.editing) {
|
if (this.props.editing) {
|
||||||
|
|
||||||
// calculate permissions. XXX: this should be done on mount or something
|
// calculate permissions. XXX: this should be done on mount or something
|
||||||
var user_id = MatrixClientPeg.get().credentials.userId;
|
const userId = MatrixClientPeg.get().credentials.userId;
|
||||||
|
|
||||||
var can_set_room_name = this.props.room.currentState.maySendStateEvent(
|
canSetRoomName = this.props.room.currentState.maySendStateEvent('m.room.name', userId);
|
||||||
'm.room.name', user_id
|
canSetRoomAvatar = this.props.room.currentState.maySendStateEvent('m.room.avatar', userId);
|
||||||
);
|
canSetRoomTopic = this.props.room.currentState.maySendStateEvent('m.room.topic', userId);
|
||||||
var can_set_room_avatar = this.props.room.currentState.maySendStateEvent(
|
|
||||||
'm.room.avatar', user_id
|
|
||||||
);
|
|
||||||
var can_set_room_topic = this.props.room.currentState.maySendStateEvent(
|
|
||||||
'm.room.topic', user_id
|
|
||||||
);
|
|
||||||
var can_set_room_name = this.props.room.currentState.maySendStateEvent(
|
|
||||||
'm.room.name', user_id
|
|
||||||
);
|
|
||||||
|
|
||||||
save_button = (
|
saveButton = (
|
||||||
<AccessibleButton className="mx_RoomHeader_textButton" onClick={this.props.onSaveClick}>
|
<AccessibleButton className="mx_RoomHeader_textButton" onClick={this.props.onSaveClick}>
|
||||||
{_t("Save")}
|
{_t("Save")}
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
|
@ -196,39 +189,41 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.onCancelClick) {
|
if (this.props.onCancelClick) {
|
||||||
cancel_button = <CancelButton onClick={this.props.onCancelClick}/>;
|
cancelButton = <CancelButton onClick={this.props.onCancelClick}/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.saving) {
|
if (this.props.saving) {
|
||||||
var Spinner = sdk.getComponent("elements.Spinner");
|
const Spinner = sdk.getComponent("elements.Spinner");
|
||||||
spinner = <div className="mx_RoomHeader_spinner"><Spinner/></div>;
|
spinner = <div className="mx_RoomHeader_spinner"><Spinner/></div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (can_set_room_name) {
|
if (canSetRoomName) {
|
||||||
var RoomNameEditor = sdk.getComponent("rooms.RoomNameEditor");
|
const RoomNameEditor = sdk.getComponent("rooms.RoomNameEditor");
|
||||||
name = <RoomNameEditor ref="nameEditor" room={this.props.room} />;
|
name = <RoomNameEditor ref="nameEditor" room={this.props.room} />;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var searchStatus;
|
|
||||||
// don't display the search count until the search completes and
|
// don't display the search count until the search completes and
|
||||||
// gives us a valid (possibly zero) searchCount.
|
// gives us a valid (possibly zero) searchCount.
|
||||||
if (this.props.searchInfo && this.props.searchInfo.searchCount !== undefined && this.props.searchInfo.searchCount !== null) {
|
if (this.props.searchInfo &&
|
||||||
searchStatus = <div className="mx_RoomHeader_searchStatus"> { _t("(~%(count)s results)", { count: this.props.searchInfo.searchCount }) }</div>;
|
this.props.searchInfo.searchCount !== undefined &&
|
||||||
|
this.props.searchInfo.searchCount !== null) {
|
||||||
|
searchStatus = <div className="mx_RoomHeader_searchStatus">
|
||||||
|
{ _t("(~%(count)s results)", { count: this.props.searchInfo.searchCount }) }
|
||||||
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: this is a bit inefficient - we could just compare room.name for 'Empty room'...
|
// XXX: this is a bit inefficient - we could just compare room.name for 'Empty room'...
|
||||||
var settingsHint = false;
|
let settingsHint = false;
|
||||||
var members = this.props.room ? this.props.room.getJoinedMembers() : undefined;
|
const members = this.props.room ? this.props.room.getJoinedMembers() : undefined;
|
||||||
if (members) {
|
if (members) {
|
||||||
if (members.length === 1 && members[0].userId === MatrixClientPeg.get().credentials.userId) {
|
if (members.length === 1 && members[0].userId === MatrixClientPeg.get().credentials.userId) {
|
||||||
var name = this.props.room.currentState.getStateEvents('m.room.name', '');
|
const nameEvent = this.props.room.currentState.getStateEvents('m.room.name', '');
|
||||||
if (!name || !name.getContent().name) {
|
if (!nameEvent || !nameEvent.getContent().name) {
|
||||||
settingsHint = true;
|
settingsHint = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var roomName = _t("Join Room");
|
let roomName = _t("Join Room");
|
||||||
if (this.props.oobData && this.props.oobData.name) {
|
if (this.props.oobData && this.props.oobData.name) {
|
||||||
roomName = this.props.oobData.name;
|
roomName = this.props.oobData.name;
|
||||||
} else if (this.props.room) {
|
} else if (this.props.room) {
|
||||||
|
@ -243,24 +238,25 @@ module.exports = React.createClass({
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (can_set_room_topic) {
|
if (canSetRoomTopic) {
|
||||||
var RoomTopicEditor = sdk.getComponent("rooms.RoomTopicEditor");
|
const RoomTopicEditor = sdk.getComponent("rooms.RoomTopicEditor");
|
||||||
topic_el = <RoomTopicEditor ref="topicEditor" room={this.props.room} />;
|
topicElement = <RoomTopicEditor ref="topicEditor" room={this.props.room} />;
|
||||||
} else {
|
} else {
|
||||||
var topic;
|
let topic;
|
||||||
if (this.props.room) {
|
if (this.props.room) {
|
||||||
var ev = this.props.room.currentState.getStateEvents('m.room.topic', '');
|
const ev = this.props.room.currentState.getStateEvents('m.room.topic', '');
|
||||||
if (ev) {
|
if (ev) {
|
||||||
topic = ev.getContent().topic;
|
topic = ev.getContent().topic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (topic) {
|
if (topic) {
|
||||||
topic_el = <EmojiText dir="auto" element="div" className="mx_RoomHeader_topic" ref="topic" title={topic}>{ topic }</EmojiText>;
|
topicElement =
|
||||||
|
<EmojiText dir="auto" element="div" className="mx_RoomHeader_topic" ref="topic" title={topic}>{ topic }</EmojiText>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var roomAvatar = null;
|
let roomAvatar = null;
|
||||||
if (can_set_room_avatar) {
|
if (canSetRoomAvatar) {
|
||||||
roomAvatar = (
|
roomAvatar = (
|
||||||
<div className="mx_RoomHeader_avatarPicker">
|
<div className="mx_RoomHeader_avatarPicker">
|
||||||
<div onClick={ this.onAvatarPickerClick }>
|
<div onClick={ this.onAvatarPickerClick }>
|
||||||
|
@ -276,8 +272,7 @@ module.exports = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
} else if (this.props.room || (this.props.oobData && this.props.oobData.name)) {
|
||||||
else if (this.props.room || (this.props.oobData && this.props.oobData.name)) {
|
|
||||||
roomAvatar = (
|
roomAvatar = (
|
||||||
<div onClick={this.props.onSettingsClick}>
|
<div onClick={this.props.onSettingsClick}>
|
||||||
<RoomAvatar room={this.props.room} width={48} height={48} oobData={this.props.oobData} />
|
<RoomAvatar room={this.props.room} width={48} height={48} oobData={this.props.oobData} />
|
||||||
|
@ -285,9 +280,8 @@ module.exports = React.createClass({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var settings_button;
|
|
||||||
if (this.props.onSettingsClick) {
|
if (this.props.onSettingsClick) {
|
||||||
settings_button =
|
settingsButton =
|
||||||
<AccessibleButton className="mx_RoomHeader_button" onClick={this.props.onSettingsClick} title={_t("Settings")}>
|
<AccessibleButton className="mx_RoomHeader_button" onClick={this.props.onSettingsClick} title={_t("Settings")}>
|
||||||
<TintableSvg src="img/icons-settings-room.svg" width="16" height="16"/>
|
<TintableSvg src="img/icons-settings-room.svg" width="16" height="16"/>
|
||||||
</AccessibleButton>;
|
</AccessibleButton>;
|
||||||
|
@ -301,61 +295,58 @@ module.exports = React.createClass({
|
||||||
// </div>;
|
// </div>;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
var forget_button;
|
let forgetButton;
|
||||||
if (this.props.onForgetClick) {
|
if (this.props.onForgetClick) {
|
||||||
forget_button =
|
forgetButton =
|
||||||
<AccessibleButton className="mx_RoomHeader_button" onClick={this.props.onForgetClick} title={ _t("Forget room") }>
|
<AccessibleButton className="mx_RoomHeader_button" onClick={this.props.onForgetClick} title={ _t("Forget room") }>
|
||||||
<TintableSvg src="img/leave.svg" width="26" height="20"/>
|
<TintableSvg src="img/leave.svg" width="26" height="20"/>
|
||||||
</AccessibleButton>;
|
</AccessibleButton>;
|
||||||
}
|
}
|
||||||
|
|
||||||
let search_button;
|
let searchButton;
|
||||||
if (this.props.onSearchClick && this.props.inRoom) {
|
if (this.props.onSearchClick && this.props.inRoom) {
|
||||||
search_button =
|
searchButton =
|
||||||
<AccessibleButton className="mx_RoomHeader_button" onClick={this.props.onSearchClick} title={ _t("Search") }>
|
<AccessibleButton className="mx_RoomHeader_button" onClick={this.props.onSearchClick} title={ _t("Search") }>
|
||||||
<TintableSvg src="img/icons-search.svg" width="35" height="35"/>
|
<TintableSvg src="img/icons-search.svg" width="35" height="35"/>
|
||||||
</AccessibleButton>;
|
</AccessibleButton>;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rightPanel_buttons;
|
let rightPanelButtons;
|
||||||
if (this.props.collapsedRhs) {
|
if (this.props.collapsedRhs) {
|
||||||
rightPanel_buttons =
|
rightPanelButtons =
|
||||||
<AccessibleButton className="mx_RoomHeader_button" onClick={this.onShowRhsClick} title={ _t('Show panel') }>
|
<AccessibleButton className="mx_RoomHeader_button" onClick={this.onShowRhsClick} title={ _t('Show panel') }>
|
||||||
<TintableSvg src="img/maximise.svg" width="10" height="16"/>
|
<TintableSvg src="img/maximise.svg" width="10" height="16"/>
|
||||||
</AccessibleButton>;
|
</AccessibleButton>;
|
||||||
}
|
}
|
||||||
|
|
||||||
var right_row;
|
let rightRow;
|
||||||
if (!this.props.editing) {
|
if (!this.props.editing) {
|
||||||
right_row =
|
rightRow =
|
||||||
<div className="mx_RoomHeader_rightRow">
|
<div className="mx_RoomHeader_rightRow">
|
||||||
{ settings_button }
|
{ settingsButton }
|
||||||
{ forget_button }
|
{ forgetButton }
|
||||||
{ search_button }
|
{ searchButton }
|
||||||
{ rightPanel_buttons }
|
{ rightPanelButtons }
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
header =
|
|
||||||
<div className="mx_RoomHeader_wrapper">
|
|
||||||
<div className="mx_RoomHeader_leftRow">
|
|
||||||
<div className="mx_RoomHeader_avatar">
|
|
||||||
{ roomAvatar }
|
|
||||||
</div>
|
|
||||||
<div className="mx_RoomHeader_info">
|
|
||||||
{ name }
|
|
||||||
{ topic_el }
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{spinner}
|
|
||||||
{save_button}
|
|
||||||
{cancel_button}
|
|
||||||
{right_row}
|
|
||||||
</div>;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ "mx_RoomHeader " + (this.props.editing ? "mx_RoomHeader_editing" : "") }>
|
<div className={ "mx_RoomHeader " + (this.props.editing ? "mx_RoomHeader_editing" : "") }>
|
||||||
{ header }
|
<div className="mx_RoomHeader_wrapper">
|
||||||
|
<div className="mx_RoomHeader_leftRow">
|
||||||
|
<div className="mx_RoomHeader_avatar">
|
||||||
|
{ roomAvatar }
|
||||||
|
</div>
|
||||||
|
<div className="mx_RoomHeader_info">
|
||||||
|
{ name }
|
||||||
|
{ topicElement }
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{spinner}
|
||||||
|
{saveButton}
|
||||||
|
{cancelButton}
|
||||||
|
{rightRow}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,11 +13,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
var React = require("react");
|
import React from 'react';
|
||||||
var dis = require("../../../dispatcher");
|
import dis from '../../../dispatcher';
|
||||||
var CallHandler = require("../../../CallHandler");
|
import CallHandler from '../../../CallHandler';
|
||||||
var sdk = require('../../../index');
|
import sdk from '../../../index';
|
||||||
var MatrixClientPeg = require("../../../MatrixClientPeg");
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
|
@ -73,10 +73,10 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
showCall: function() {
|
showCall: function() {
|
||||||
var call;
|
let call;
|
||||||
|
|
||||||
if (this.props.room) {
|
if (this.props.room) {
|
||||||
var roomId = this.props.room.roomId;
|
const roomId = this.props.room.roomId;
|
||||||
call = CallHandler.getCallForRoom(roomId) ||
|
call = CallHandler.getCallForRoom(roomId) ||
|
||||||
(this.props.ConferenceHandler ?
|
(this.props.ConferenceHandler ?
|
||||||
this.props.ConferenceHandler.getConferenceCallForRoom(roomId) :
|
this.props.ConferenceHandler.getConferenceCallForRoom(roomId) :
|
||||||
|
@ -86,9 +86,7 @@ module.exports = React.createClass({
|
||||||
if (this.call) {
|
if (this.call) {
|
||||||
this.setState({ call: call });
|
this.setState({ call: call });
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
call = CallHandler.getAnyActiveCall();
|
call = CallHandler.getAnyActiveCall();
|
||||||
this.setState({ call: call });
|
this.setState({ call: call });
|
||||||
}
|
}
|
||||||
|
@ -109,8 +107,7 @@ module.exports = React.createClass({
|
||||||
call.confUserId ? "none" : "block"
|
call.confUserId ? "none" : "block"
|
||||||
);
|
);
|
||||||
this.getVideoView().getRemoteVideoElement().style.display = "block";
|
this.getVideoView().getRemoteVideoElement().style.display = "block";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.getVideoView().getLocalVideoElement().style.display = "none";
|
this.getVideoView().getLocalVideoElement().style.display = "none";
|
||||||
this.getVideoView().getRemoteVideoElement().style.display = "none";
|
this.getVideoView().getRemoteVideoElement().style.display = "none";
|
||||||
dis.dispatch({action: 'video_fullscreen', fullscreen: false});
|
dis.dispatch({action: 'video_fullscreen', fullscreen: false});
|
||||||
|
@ -126,11 +123,11 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var VideoView = sdk.getComponent('voip.VideoView');
|
const VideoView = sdk.getComponent('voip.VideoView');
|
||||||
|
|
||||||
var voice;
|
let voice;
|
||||||
if (this.state.call && this.state.call.type === "voice" && this.props.showVoice) {
|
if (this.state.call && this.state.call.type === "voice" && this.props.showVoice) {
|
||||||
var callRoom = MatrixClientPeg.get().getRoom(this.state.call.roomId);
|
const callRoom = MatrixClientPeg.get().getRoom(this.state.call.roomId);
|
||||||
voice = (
|
voice = (
|
||||||
<div className="mx_CallView_voice" onClick={ this.props.onClick }>
|
<div className="mx_CallView_voice" onClick={ this.props.onClick }>
|
||||||
{_t("Active call (%(roomName)s)", {roomName: callRoom.name})}
|
{_t("Active call (%(roomName)s)", {roomName: callRoom.name})}
|
||||||
|
@ -147,6 +144,6 @@ module.exports = React.createClass({
|
||||||
{ voice }
|
{ voice }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
var React = require('react');
|
import React from 'react';
|
||||||
var MatrixClientPeg = require('../../../MatrixClientPeg');
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
var dis = require("../../../dispatcher");
|
import dis from '../../../dispatcher';
|
||||||
var CallHandler = require("../../../CallHandler");
|
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
|
@ -29,34 +28,32 @@ module.exports = React.createClass({
|
||||||
onAnswerClick: function() {
|
onAnswerClick: function() {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'answer',
|
action: 'answer',
|
||||||
room_id: this.props.incomingCall.roomId
|
room_id: this.props.incomingCall.roomId,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onRejectClick: function() {
|
onRejectClick: function() {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'hangup',
|
action: 'hangup',
|
||||||
room_id: this.props.incomingCall.roomId
|
room_id: this.props.incomingCall.roomId,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var room = null;
|
let room = null;
|
||||||
if (this.props.incomingCall) {
|
if (this.props.incomingCall) {
|
||||||
room = MatrixClientPeg.get().getRoom(this.props.incomingCall.roomId);
|
room = MatrixClientPeg.get().getRoom(this.props.incomingCall.roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
var caller = room ? room.name : _t("unknown caller");
|
const caller = room ? room.name : _t("unknown caller");
|
||||||
|
|
||||||
let incomingCallText = null;
|
let incomingCallText = null;
|
||||||
if (this.props.incomingCall) {
|
if (this.props.incomingCall) {
|
||||||
if (this.props.incomingCall.type === "voice") {
|
if (this.props.incomingCall.type === "voice") {
|
||||||
incomingCallText = _t("Incoming voice call from %(name)s", {name: caller});
|
incomingCallText = _t("Incoming voice call from %(name)s", {name: caller});
|
||||||
}
|
} else if (this.props.incomingCall.type === "video") {
|
||||||
else if (this.props.incomingCall.type === "video") {
|
|
||||||
incomingCallText = _t("Incoming video call from %(name)s", {name: caller});
|
incomingCallText = _t("Incoming video call from %(name)s", {name: caller});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
incomingCallText = _t("Incoming call from %(name)s", {name: caller});
|
incomingCallText = _t("Incoming call from %(name)s", {name: caller});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,6 +78,6 @@ module.exports = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var React = require('react');
|
import React from 'react';
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'VideoFeed',
|
displayName: 'VideoFeed',
|
||||||
|
|
|
@ -16,11 +16,11 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var React = require('react');
|
import React from 'react';
|
||||||
var ReactDOM = require('react-dom');
|
import ReactDOM from 'react-dom';
|
||||||
|
|
||||||
var sdk = require('../../../index');
|
import sdk from '../../../index';
|
||||||
var dis = require('../../../dispatcher');
|
import dis from '../../../dispatcher';
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'VideoView',
|
displayName: 'VideoView',
|
||||||
|
@ -53,9 +53,10 @@ module.exports = React.createClass({
|
||||||
// this needs to be somewhere at the top of the DOM which
|
// this needs to be somewhere at the top of the DOM which
|
||||||
// always exists to avoid audio interruptions.
|
// always exists to avoid audio interruptions.
|
||||||
// Might as well just use DOM.
|
// Might as well just use DOM.
|
||||||
var remoteAudioElement = document.getElementById("remoteAudio");
|
const remoteAudioElement = document.getElementById("remoteAudio");
|
||||||
if (!remoteAudioElement) {
|
if (!remoteAudioElement) {
|
||||||
console.error("Failed to find remoteAudio element - cannot play audio! You need to add an <audio/> to the DOM.");
|
console.error("Failed to find remoteAudio element - cannot play audio!"
|
||||||
|
+ "You need to add an <audio/> to the DOM.");
|
||||||
}
|
}
|
||||||
return remoteAudioElement;
|
return remoteAudioElement;
|
||||||
},
|
},
|
||||||
|
@ -70,22 +71,21 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
onAction: function(payload) {
|
onAction: function(payload) {
|
||||||
switch (payload.action) {
|
switch (payload.action) {
|
||||||
case 'video_fullscreen':
|
case 'video_fullscreen': {
|
||||||
if (!this.container) {
|
if (!this.container) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var element = this.container;
|
const element = this.container;
|
||||||
if (payload.fullscreen) {
|
if (payload.fullscreen) {
|
||||||
var requestMethod = (
|
const requestMethod = (
|
||||||
element.requestFullScreen ||
|
element.requestFullScreen ||
|
||||||
element.webkitRequestFullScreen ||
|
element.webkitRequestFullScreen ||
|
||||||
element.mozRequestFullScreen ||
|
element.mozRequestFullScreen ||
|
||||||
element.msRequestFullscreen
|
element.msRequestFullscreen
|
||||||
);
|
);
|
||||||
requestMethod.call(element);
|
requestMethod.call(element);
|
||||||
}
|
} else {
|
||||||
else {
|
const exitMethod = (
|
||||||
var exitMethod = (
|
|
||||||
document.exitFullscreen ||
|
document.exitFullscreen ||
|
||||||
document.mozCancelFullScreen ||
|
document.mozCancelFullScreen ||
|
||||||
document.webkitExitFullscreen ||
|
document.webkitExitFullscreen ||
|
||||||
|
@ -96,17 +96,18 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var VideoFeed = sdk.getComponent('voip.VideoFeed');
|
const VideoFeed = sdk.getComponent('voip.VideoFeed');
|
||||||
|
|
||||||
// if we're fullscreen, we don't want to set a maxHeight on the video element.
|
// if we're fullscreen, we don't want to set a maxHeight on the video element.
|
||||||
var fullscreenElement = (document.fullscreenElement ||
|
const fullscreenElement = (document.fullscreenElement ||
|
||||||
document.mozFullScreenElement ||
|
document.mozFullScreenElement ||
|
||||||
document.webkitFullscreenElement);
|
document.webkitFullscreenElement);
|
||||||
var maxVideoHeight = fullscreenElement ? null : this.props.maxHeight;
|
const maxVideoHeight = fullscreenElement ? null : this.props.maxHeight;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_VideoView" ref={this.setContainer} onClick={ this.props.onClick }>
|
<div className="mx_VideoView" ref={this.setContainer} onClick={ this.props.onClick }>
|
||||||
|
@ -119,5 +120,5 @@ module.exports = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,24 +14,24 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var MatrixClientPeg = require('./MatrixClientPeg');
|
import MatrixClientPeg from './MatrixClientPeg';
|
||||||
var Modal = require('./Modal');
|
import Modal from './Modal';
|
||||||
var sdk = require('./index');
|
import sdk from './index';
|
||||||
import { _t } from './languageHandler';
|
import { _t } from './languageHandler';
|
||||||
var dis = require("./dispatcher");
|
import dis from "./dispatcher";
|
||||||
var Rooms = require("./Rooms");
|
import Rooms from "./Rooms";
|
||||||
|
|
||||||
var q = require('q');
|
import q from 'q';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new room, and switch to it.
|
* Create a new room, and switch to it.
|
||||||
*
|
*
|
||||||
* Returns a promise which resolves to the room id, or null if the
|
|
||||||
* action was aborted or failed.
|
|
||||||
*
|
|
||||||
* @param {object=} opts parameters for creating the room
|
* @param {object=} opts parameters for creating the room
|
||||||
* @param {string=} opts.dmUserId If specified, make this a DM room for this user and invite them
|
* @param {string=} opts.dmUserId If specified, make this a DM room for this user and invite them
|
||||||
* @param {object=} opts.createOpts set of options to pass to createRoom call.
|
* @param {object=} opts.createOpts set of options to pass to createRoom call.
|
||||||
|
*
|
||||||
|
* @returns {Promise} which resolves to the room id, or null if the
|
||||||
|
* action was aborted or failed.
|
||||||
*/
|
*/
|
||||||
function createRoom(opts) {
|
function createRoom(opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
@ -69,11 +69,11 @@ function createRoom(opts) {
|
||||||
createOpts.initial_state = createOpts.initial_state || [
|
createOpts.initial_state = createOpts.initial_state || [
|
||||||
{
|
{
|
||||||
content: {
|
content: {
|
||||||
guest_access: 'can_join'
|
guest_access: 'can_join',
|
||||||
},
|
},
|
||||||
type: 'm.room.guest_access',
|
type: 'm.room.guest_access',
|
||||||
state_key: '',
|
state_key: '',
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const modal = Modal.createDialog(Loader, null, 'mx_Dialog_spinner');
|
const modal = Modal.createDialog(Loader, null, 'mx_Dialog_spinner');
|
||||||
|
|
|
@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var EMAIL_ADDRESS_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
const EMAIL_ADDRESS_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
looksValid: function(email) {
|
looksValid: function(email) {
|
||||||
return EMAIL_ADDRESS_REGEX.test(email);
|
return EMAIL_ADDRESS_REGEX.test(email);
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = function(dest, src) {
|
module.exports = function(dest, src) {
|
||||||
for (var i in src) {
|
for (const i in src) {
|
||||||
if (src.hasOwnProperty(i)) {
|
if (src.hasOwnProperty(i)) {
|
||||||
dest[i] = src[i];
|
dest[i] = src[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ class LifecycleStore extends Store {
|
||||||
deferred_action: null,
|
deferred_action: null,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'sync_state':
|
case 'sync_state': {
|
||||||
if (payload.state !== 'PREPARED') {
|
if (payload.state !== 'PREPARED') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ class LifecycleStore extends Store {
|
||||||
});
|
});
|
||||||
dis.dispatch(deferredAction);
|
dis.dispatch(deferredAction);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'on_logged_out':
|
case 'on_logged_out':
|
||||||
this.reset();
|
this.reset();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue