Merge remote-tracking branch 'origin/develop' into dbkr/wait_for_user_verified
This commit is contained in:
commit
064d90c4b5
4 changed files with 504 additions and 433 deletions
13
src/@types/global.d.ts
vendored
13
src/@types/global.d.ts
vendored
|
@ -37,4 +37,17 @@ declare global {
|
||||||
interface StorageEstimate {
|
interface StorageEstimate {
|
||||||
usageDetails?: {[key: string]: number};
|
usageDetails?: {[key: string]: number};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ISettledFulfilled<T> {
|
||||||
|
status: "fulfilled";
|
||||||
|
value: T;
|
||||||
|
}
|
||||||
|
export interface ISettledRejected {
|
||||||
|
status: "rejected";
|
||||||
|
reason: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PromiseConstructor {
|
||||||
|
allSettled<T>(promises: Promise<T>[]): Promise<Array<ISettledFulfilled<T> | ISettledRejected>>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -425,7 +425,7 @@ export default createReactClass({
|
||||||
}
|
}
|
||||||
this.onResize();
|
this.onResize();
|
||||||
|
|
||||||
document.addEventListener("keydown", this.onKeyDown);
|
document.addEventListener("keydown", this.onNativeKeyDown);
|
||||||
},
|
},
|
||||||
|
|
||||||
shouldComponentUpdate: function(nextProps, nextState) {
|
shouldComponentUpdate: function(nextProps, nextState) {
|
||||||
|
@ -508,7 +508,7 @@ export default createReactClass({
|
||||||
this.props.resizeNotifier.removeListener("middlePanelResized", this.onResize);
|
this.props.resizeNotifier.removeListener("middlePanelResized", this.onResize);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.removeEventListener("keydown", this.onKeyDown);
|
document.removeEventListener("keydown", this.onNativeKeyDown);
|
||||||
|
|
||||||
// Remove RoomStore listener
|
// Remove RoomStore listener
|
||||||
if (this._roomStoreToken) {
|
if (this._roomStoreToken) {
|
||||||
|
@ -550,7 +550,8 @@ export default createReactClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyDown: function(ev) {
|
// we register global shortcuts here, they *must not conflict* with local shortcuts elsewhere or both will fire
|
||||||
|
onNativeKeyDown: function(ev) {
|
||||||
let handled = false;
|
let handled = false;
|
||||||
const ctrlCmdOnly = isOnlyCtrlOrCmdKeyEvent(ev);
|
const ctrlCmdOnly = isOnlyCtrlOrCmdKeyEvent(ev);
|
||||||
|
|
||||||
|
@ -576,6 +577,25 @@ export default createReactClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onReactKeyDown: function(ev) {
|
||||||
|
let handled = false;
|
||||||
|
|
||||||
|
switch (ev.key) {
|
||||||
|
case Key.ESCAPE:
|
||||||
|
if (!ev.altKey && !ev.ctrlKey && !ev.shiftKey && !ev.metaKey) {
|
||||||
|
this._messagePanel.forgetReadMarker();
|
||||||
|
this.jumpToLiveTimeline();
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handled) {
|
||||||
|
ev.stopPropagation();
|
||||||
|
ev.preventDefault();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onAction: function(payload) {
|
onAction: function(payload) {
|
||||||
switch (payload.action) {
|
switch (payload.action) {
|
||||||
case 'message_send_failed':
|
case 'message_send_failed':
|
||||||
|
@ -1768,7 +1788,7 @@ export default createReactClass({
|
||||||
const showRoomRecoveryReminder = (
|
const showRoomRecoveryReminder = (
|
||||||
SettingsStore.getValue("showRoomRecoveryReminder") &&
|
SettingsStore.getValue("showRoomRecoveryReminder") &&
|
||||||
this.context.isRoomEncrypted(this.state.room.roomId) &&
|
this.context.isRoomEncrypted(this.state.room.roomId) &&
|
||||||
!this.context.getKeyBackupEnabled()
|
this.context.getKeyBackupEnabled() === false
|
||||||
);
|
);
|
||||||
|
|
||||||
const hiddenHighlightCount = this._getHiddenHighlightCount();
|
const hiddenHighlightCount = this._getHiddenHighlightCount();
|
||||||
|
@ -2008,9 +2028,13 @@ export default createReactClass({
|
||||||
mx_RoomView_timeline_rr_enabled: this.state.showReadReceipts,
|
mx_RoomView_timeline_rr_enabled: this.state.showReadReceipts,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const mainClasses = classNames("mx_RoomView", {
|
||||||
|
mx_RoomView_inCall: inCall,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RoomContext.Provider value={this.state}>
|
<RoomContext.Provider value={this.state}>
|
||||||
<main className={"mx_RoomView" + (inCall ? " mx_RoomView_inCall" : "")} ref={this._roomView}>
|
<main className={mainClasses} ref={this._roomView} onKeyDown={this.onReactKeyDown}>
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<RoomHeader
|
<RoomHeader
|
||||||
room={this.state.room}
|
room={this.state.room}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2019 The Matrix.org Foundation C.I.C.
|
Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// @flow
|
|
||||||
|
|
||||||
// Returns a promise which resolves with a given value after the given number of ms
|
// Returns a promise which resolves with a given value after the given number of ms
|
||||||
export const sleep = (ms: number, value: any): Promise => new Promise((resolve => { setTimeout(resolve, ms, value); }));
|
export function sleep<T>(ms: number, value: T): Promise<T> {
|
||||||
|
return new Promise((resolve => { setTimeout(resolve, ms, value); }));
|
||||||
|
}
|
||||||
|
|
||||||
// Returns a promise which resolves when the input promise resolves with its value
|
// Returns a promise which resolves when the input promise resolves with its value
|
||||||
// or when the timeout of ms is reached with the value of given timeoutValue
|
// or when the timeout of ms is reached with the value of given timeoutValue
|
||||||
export async function timeout(promise: Promise, timeoutValue: any, ms: number): Promise {
|
export async function timeout<T>(promise: Promise<T>, timeoutValue: T, ms: number): Promise<T> {
|
||||||
const timeoutPromise = new Promise((resolve) => {
|
const timeoutPromise = new Promise<T>((resolve) => {
|
||||||
const timeoutId = setTimeout(resolve, ms, timeoutValue);
|
const timeoutId = setTimeout(resolve, ms, timeoutValue);
|
||||||
promise.then(() => {
|
promise.then(() => {
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
|
@ -32,12 +32,18 @@ export async function timeout(promise: Promise, timeoutValue: any, ms: number):
|
||||||
return Promise.race([promise, timeoutPromise]);
|
return Promise.race([promise, timeoutPromise]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IDeferred<T> {
|
||||||
|
resolve: (value: T) => void;
|
||||||
|
reject: (any) => void;
|
||||||
|
promise: Promise<T>;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns a Deferred
|
// Returns a Deferred
|
||||||
export function defer(): {resolve: () => {}, reject: () => {}, promise: Promise} {
|
export function defer<T>(): IDeferred<T> {
|
||||||
let resolve;
|
let resolve;
|
||||||
let reject;
|
let reject;
|
||||||
|
|
||||||
const promise = new Promise((_resolve, _reject) => {
|
const promise = new Promise<T>((_resolve, _reject) => {
|
||||||
resolve = _resolve;
|
resolve = _resolve;
|
||||||
reject = _reject;
|
reject = _reject;
|
||||||
});
|
});
|
||||||
|
@ -46,11 +52,12 @@ export function defer(): {resolve: () => {}, reject: () => {}, promise: Promise}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Promise.allSettled polyfill until browser support is stable in Firefox
|
// Promise.allSettled polyfill until browser support is stable in Firefox
|
||||||
export function allSettled(promises: Promise[]): {status: string, value?: any, reason?: any}[] {
|
export function allSettled<T>(promises: Promise<T>[]): Promise<Array<ISettledFulfilled<T> | ISettledRejected>> {
|
||||||
if (Promise.allSettled) {
|
if (Promise.allSettled) {
|
||||||
return Promise.allSettled(promises);
|
return Promise.allSettled<T>(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore - typescript isn't smart enough to see the disjoint here
|
||||||
return Promise.all(promises.map((promise) => {
|
return Promise.all(promises.map((promise) => {
|
||||||
return promise.then(value => ({
|
return promise.then(value => ({
|
||||||
status: "fulfilled",
|
status: "fulfilled",
|
Loading…
Add table
Add a link
Reference in a new issue