Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/feat/widgets

 Conflicts:
	src/resizer/distributors/collapse.ts
	src/resizer/distributors/fixed.ts
	src/resizer/index.ts
	src/resizer/item.ts
	src/resizer/resizer.ts
	src/resizer/sizer.ts
This commit is contained in:
Michael Telatynski 2020-10-21 09:56:22 +01:00
commit a5468c918e
17 changed files with 66 additions and 75 deletions

View file

@ -1,3 +1,12 @@
Changes in [3.6.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.6.1) (2020-10-20)
===================================================================================================
[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v3.6.0...v3.6.1)
* [Release] Adjust for new widget messaging APIs
[\#5342](https://github.com/matrix-org/matrix-react-sdk/pull/5342)
* [Release] Fix Jitsi OpenIDC auth
[\#5335](https://github.com/matrix-org/matrix-react-sdk/pull/5335)
Changes in [3.6.0](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.6.0) (2020-10-12) Changes in [3.6.0](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.6.0) (2020-10-12)
=================================================================================================== ===================================================================================================
[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v3.6.0-rc.1...v3.6.0) [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v3.6.0-rc.1...v3.6.0)

View file

@ -1,6 +1,6 @@
{ {
"name": "matrix-react-sdk", "name": "matrix-react-sdk",
"version": "3.6.0", "version": "3.6.1",
"description": "SDK for matrix.org using React", "description": "SDK for matrix.org using React",
"author": "matrix.org", "author": "matrix.org",
"repository": { "repository": {

View file

@ -32,9 +32,7 @@ do
echo "Upgrading $i to $latestver..." echo "Upgrading $i to $latestver..."
yarn add -E $i@$latestver yarn add -E $i@$latestver
git add -u git add -u
# The `-e` flag opens the editor and gives you a chance to check git commit -m "Upgrade $i to $latestver"
# the upgrade for correctness.
git commit -m "Upgrade $i to $latestver" -e
fi fi
fi fi
done done

View file

@ -230,6 +230,10 @@ limitations under the License.
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
&.mx_UserMenu_contextMenu_hostingLink {
padding-top: 0;
}
} }
.mx_IconizedContextMenu_icon { .mx_IconizedContextMenu_icon {

View file

@ -360,7 +360,7 @@ function combineEvents(previousSearchResult, localEvents = undefined, serverEven
let oldestEventFrom = previousSearchResult.oldestEventFrom; let oldestEventFrom = previousSearchResult.oldestEventFrom;
response.highlights = previousSearchResult.highlights; response.highlights = previousSearchResult.highlights;
if (localEvents && serverEvents) { if (localEvents && serverEvents && serverEvents.results) {
// This is a first search call, combine the events from the server and // This is a first search call, combine the events from the server and
// the local index. Note where our oldest event came from, we shall // the local index. Note where our oldest event came from, we shall
// fetch the next batch of events from the other source. // fetch the next batch of events from the other source.
@ -379,7 +379,7 @@ function combineEvents(previousSearchResult, localEvents = undefined, serverEven
oldestEventFrom = "local"; oldestEventFrom = "local";
} }
combineEventSources(previousSearchResult, response, localEvents.results, cachedEvents); combineEventSources(previousSearchResult, response, localEvents.results, cachedEvents);
} else if (serverEvents) { } else if (serverEvents && serverEvents.results) {
// This is a pagination call fetching more events from the server, // This is a pagination call fetching more events from the server,
// meaning that our oldest event was in the local index. // meaning that our oldest event was in the local index.
// Change the source of the oldest event if our server event is older // Change the source of the oldest event if our server event is older
@ -454,7 +454,7 @@ function combineResponses(previousSearchResult, localEvents = undefined, serverE
return response; return response;
} }
function restoreEncryptionInfo(searchResultSlice) { function restoreEncryptionInfo(searchResultSlice = []) {
for (let i = 0; i < searchResultSlice.length; i++) { for (let i = 0; i < searchResultSlice.length; i++) {
const timeline = searchResultSlice[i].context.getTimeline(); const timeline = searchResultSlice[i].context.getTimeline();
@ -517,7 +517,7 @@ async function combinedPagination(searchResult) {
}, },
}; };
const oldResultCount = searchResult.results.length; const oldResultCount = searchResult.results ? searchResult.results.length : 0;
// Let the client process the combined result. // Let the client process the combined result.
const result = client._processRoomEventsSearch(searchResult, response); const result = client._processRoomEventsSearch(searchResult, response);

View file

@ -388,7 +388,6 @@ export default class LeftPanel extends React.Component<IProps, IState> {
const roomList = <RoomList const roomList = <RoomList
onKeyDown={this.onKeyDown} onKeyDown={this.onKeyDown}
resizeNotifier={null} resizeNotifier={null}
collapsed={false}
onFocus={this.onFocus} onFocus={this.onFocus}
onBlur={this.onBlur} onBlur={this.onBlur}
isMinimized={this.props.isMinimized} isMinimized={this.props.isMinimized}

View file

@ -52,6 +52,7 @@ import RoomListStore from "../../stores/room-list/RoomListStore";
import NonUrgentToastContainer from "./NonUrgentToastContainer"; import NonUrgentToastContainer from "./NonUrgentToastContainer";
import { ToggleRightPanelPayload } from "../../dispatcher/payloads/ToggleRightPanelPayload"; import { ToggleRightPanelPayload } from "../../dispatcher/payloads/ToggleRightPanelPayload";
import { IThreepidInvite } from "../../stores/ThreepidInviteStore"; import { IThreepidInvite } from "../../stores/ThreepidInviteStore";
import { ICollapseConfig } from "../../resizer/distributors/collapse";
// We need to fetch each pinned message individually (if we don't already have it) // We need to fetch each pinned message individually (if we don't already have it)
// so each pinned message may trigger a request. Limit the number per room for sanity. // so each pinned message may trigger a request. Limit the number per room for sanity.
@ -205,13 +206,8 @@ class LoggedInView extends React.Component<IProps, IState> {
}; };
_createResizer() { _createResizer() {
const classNames = {
handle: "mx_ResizeHandle",
vertical: "mx_ResizeHandle_vertical",
reverse: "mx_ResizeHandle_reverse",
};
let size; let size;
const collapseConfig = { const collapseConfig: ICollapseConfig = {
toggleSize: 260 - 50, toggleSize: 260 - 50,
onCollapsed: (collapsed) => { onCollapsed: (collapsed) => {
if (collapsed) { if (collapsed) {
@ -234,7 +230,11 @@ class LoggedInView extends React.Component<IProps, IState> {
}, },
}; };
const resizer = new Resizer(this._resizeContainer.current, CollapseDistributor, collapseConfig); const resizer = new Resizer(this._resizeContainer.current, CollapseDistributor, collapseConfig);
resizer.setClassNames(classNames); resizer.setClassNames({
handle: "mx_ResizeHandle",
vertical: "mx_ResizeHandle_vertical",
reverse: "mx_ResizeHandle_reverse",
});
return resizer; return resizer;
} }

View file

@ -1277,7 +1277,7 @@ export default class RoomView extends React.Component<IProps, IState> {
} }
if (!this.state.searchResults.next_batch) { if (!this.state.searchResults.next_batch) {
if (this.state.searchResults.results.length == 0) { if (!this.state.searchResults?.results?.length) {
ret.push(<li key="search-top-marker"> ret.push(<li key="search-top-marker">
<h2 className="mx_RoomView_topMarker">{ _t("No results") }</h2> <h2 className="mx_RoomView_topMarker">{ _t("No results") }</h2>
</li>, </li>,
@ -1301,7 +1301,7 @@ export default class RoomView extends React.Component<IProps, IState> {
let lastRoomId; let lastRoomId;
for (let i = this.state.searchResults.results.length - 1; i >= 0; i--) { for (let i = (this.state.searchResults?.results?.length || 0) - 1; i >= 0; i--) {
const result = this.state.searchResults.results[i]; const result = this.state.searchResults.results[i];
const mxEv = result.context.getEvent(); const mxEv = result.context.getEvent();
@ -1970,7 +1970,7 @@ export default class RoomView extends React.Component<IProps, IState> {
if (this.state.searchResults) { if (this.state.searchResults) {
// show searching spinner // show searching spinner
if (this.state.searchResults.results === undefined) { if (this.state.searchResults.count === undefined) {
searchResultsPanel = ( searchResultsPanel = (
<div className="mx_RoomView_messagePanel mx_RoomView_messagePanelSearchSpinner" /> <div className="mx_RoomView_messagePanel mx_RoomView_messagePanelSearchSpinner" />
); );

View file

@ -257,7 +257,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
const signupLink = getHostingLink("user-context-menu"); const signupLink = getHostingLink("user-context-menu");
if (signupLink) { if (signupLink) {
hostingLink = ( hostingLink = (
<div className="mx_UserMenu_contextMenu_header"> <div className="mx_UserMenu_contextMenu_header mx_UserMenu_contextMenu_hostingLink">
{_t( {_t(
"<a>Upgrade</a> to your own domain", {}, "<a>Upgrade</a> to your own domain", {},
{ {

View file

@ -53,7 +53,6 @@ interface IProps {
onBlur: (ev: React.FocusEvent) => void; onBlur: (ev: React.FocusEvent) => void;
onResize: () => void; onResize: () => void;
resizeNotifier: ResizeNotifier; resizeNotifier: ResizeNotifier;
collapsed: boolean;
isMinimized: boolean; isMinimized: boolean;
} }
@ -366,7 +365,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
public render() { public render() {
let explorePrompt: JSX.Element; let explorePrompt: JSX.Element;
if (RoomListStore.instance.getFirstNameFilterCondition()) { if (!this.props.isMinimized && RoomListStore.instance.getFirstNameFilterCondition()) {
explorePrompt = <div className="mx_RoomList_explorePrompt"> explorePrompt = <div className="mx_RoomList_explorePrompt">
<div>{_t("Can't see what youre looking for?")}</div> <div>{_t("Can't see what youre looking for?")}</div>
<AccessibleButton kind="link" onClick={this.onExplore}> <AccessibleButton kind="link" onClick={this.onExplore}>

View file

@ -1,5 +1,5 @@
/* /*
Copyright 2019 New Vector Ltd 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.
@ -16,9 +16,10 @@ limitations under the License.
import FixedDistributor from "./fixed"; import FixedDistributor from "./fixed";
import ResizeItem from "../item"; import ResizeItem from "../item";
import {IConfig} from "../resizer"; import Resizer, {IConfig} from "../resizer";
import Sizer from "../sizer";
interface ICollapseConfig extends IConfig { export interface ICollapseConfig extends IConfig {
toggleSize: number; toggleSize: number;
onCollapsed?(collapsed: boolean, id: string, element: HTMLElement): void; onCollapsed?(collapsed: boolean, id: string, element: HTMLElement): void;
} }
@ -33,17 +34,16 @@ class CollapseItem extends ResizeItem<ICollapseConfig> {
} }
export default class CollapseDistributor extends FixedDistributor<ICollapseConfig, CollapseItem> { export default class CollapseDistributor extends FixedDistributor<ICollapseConfig, CollapseItem> {
static createItem(resizeHandle, resizer, sizer) { static createItem(resizeHandle: HTMLDivElement, resizer: Resizer<ICollapseConfig>, sizer: Sizer) {
return new CollapseItem(resizeHandle, resizer, sizer); return new CollapseItem(resizeHandle, resizer, sizer);
} }
private readonly toggleSize: number; private readonly toggleSize: number;
private isCollapsed: boolean; private isCollapsed = false;
constructor(item: CollapseItem) { constructor(item: CollapseItem) {
super(item); super(item);
this.toggleSize = item.resizer?.config?.toggleSize; this.toggleSize = item.resizer?.config?.toggleSize;
this.isCollapsed = false;
} }
public resize(newSize: number) { public resize(newSize: number) {

View file

@ -1,5 +1,5 @@
/* /*
Copyright 2019 New Vector Ltd 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.
@ -29,11 +29,11 @@ they have two methods:
This method usually ends up calling `resize` once the start offset is subtracted. This method usually ends up calling `resize` once the start offset is subtracted.
*/ */
export default class FixedDistributor<C extends IConfig, I extends ResizeItem<any> = ResizeItem<C>> { export default class FixedDistributor<C extends IConfig, I extends ResizeItem<any> = ResizeItem<C>> {
static createItem(resizeHandle: HTMLDivElement, resizer: Resizer, sizer: Sizer) { static createItem(resizeHandle: HTMLDivElement, resizer: Resizer, sizer: Sizer): ResizeItem {
return new ResizeItem(resizeHandle, resizer, sizer); return new ResizeItem(resizeHandle, resizer, sizer);
} }
static createSizer(containerElement: HTMLElement, vertical: boolean, reverse: boolean) { static createSizer(containerElement: HTMLElement, vertical: boolean, reverse: boolean): Sizer {
return new Sizer(containerElement, vertical, reverse); return new Sizer(containerElement, vertical, reverse);
} }

View file

@ -1,5 +1,4 @@
/* /*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C. Copyright 2019 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");

View file

@ -1,6 +1,5 @@
/* /*
Copyright 2019 New Vector Ltd Copyright 2019 - 2020 The Matrix.org Foundation C.I.C.
Copyright 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.
@ -15,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import Sizer from "./sizer";
import Resizer, {IConfig} from "./resizer"; import Resizer, {IConfig} from "./resizer";
import Sizer from "./sizer";
export default class ResizeItem<C extends IConfig = IConfig> { export default class ResizeItem<C extends IConfig = IConfig> {
public readonly domNode: HTMLElement; public readonly domNode: HTMLElement;
@ -28,38 +27,31 @@ export default class ResizeItem<C extends IConfig = IConfig> {
public readonly resizer: Resizer<C>, public readonly resizer: Resizer<C>,
public readonly sizer: Sizer, public readonly sizer: Sizer,
) { ) {
const id = handle.getAttribute("data-id"); this.reverse = resizer.isReverseResizeHandle(handle);
const reverse = resizer.isReverseResizeHandle(handle); this.domNode = <HTMLElement>(this.reverse ? handle.nextElementSibling : handle.previousElementSibling);
this.id = handle.getAttribute("data-id");
this.domNode = <HTMLElement>(reverse ? handle.nextElementSibling : handle.previousElementSibling);
this.id = id;
this.reverse = reverse;
this.resizer = resizer;
this.sizer = sizer;
} }
private copyWith(handle: Element, resizer: Resizer, sizer: Sizer) { private copyWith(handle: HTMLElement, resizer: Resizer, sizer: Sizer) {
const Ctor = this.constructor as typeof ResizeItem; const Ctor = this.constructor as typeof ResizeItem;
return new Ctor(<HTMLElement>handle, resizer, sizer); return new Ctor(handle, resizer, sizer);
} }
private advance(forwards: boolean) { private advance(forwards: boolean) {
// opposite direction from fromResizeHandle to get back to handle // opposite direction from fromResizeHandle to get back to handle
let handle = <HTMLElement>(this.reverse ? let handle = this.reverse ? this.domNode.previousElementSibling : this.domNode.nextElementSibling;
this.domNode.previousElementSibling :
this.domNode.nextElementSibling);
const moveNext = forwards !== this.reverse; // xor const moveNext = forwards !== this.reverse; // xor
// iterate at least once to avoid infinite loop // iterate at least once to avoid infinite loop
do { do {
if (moveNext) { if (moveNext) {
handle = <HTMLElement>handle.nextElementSibling; handle = handle.nextElementSibling;
} else { } else {
handle = <HTMLElement>handle.previousElementSibling; handle = handle.previousElementSibling;
} }
} while (handle && !this.resizer.isResizeHandle(handle)); } while (handle && !this.resizer.isResizeHandle(<HTMLElement>handle));
if (handle) { if (handle) {
const nextHandle = this.copyWith(handle, this.resizer, this.sizer); const nextHandle = this.copyWith(<HTMLElement>handle, this.resizer, this.sizer);
nextHandle.reverse = this.reverse; nextHandle.reverse = this.reverse;
return nextHandle; return nextHandle;
} }
@ -118,7 +110,7 @@ export default class ResizeItem<C extends IConfig = IConfig> {
return this.resizer.isResizeHandle(<HTMLElement>el); return this.resizer.isResizeHandle(<HTMLElement>el);
}); });
if (firstHandle) { if (firstHandle) {
return this.copyWith(firstHandle, this.resizer, this.sizer); return this.copyWith(<HTMLElement>firstHandle, this.resizer, this.sizer);
} }
} }
@ -127,7 +119,7 @@ export default class ResizeItem<C extends IConfig = IConfig> {
return this.resizer.isResizeHandle(<HTMLElement>el); return this.resizer.isResizeHandle(<HTMLElement>el);
}); });
if (lastHandle) { if (lastHandle) {
return this.copyWith(lastHandle, this.resizer, this.sizer); return this.copyWith(<HTMLElement>lastHandle, this.resizer, this.sizer);
} }
} }
} }

View file

@ -1,6 +1,5 @@
/* /*
Copyright 2018 New Vector Ltd Copyright 2018 - 2020 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.
@ -15,28 +14,20 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
/*
classNames:
// class on resize-handle
handle: string
// class on resize-handle
reverse: string
// class on resize-handle
vertical: string
// class on container
resizing: string
*/
import {throttle} from "lodash"; import {throttle} from "lodash";
import FixedDistributor from "./distributors/fixed"; import FixedDistributor from "./distributors/fixed";
import Sizer from "./sizer";
import ResizeItem from "./item"; import ResizeItem from "./item";
import Sizer from "./sizer";
interface IClassNames { interface IClassNames {
// class on resize-handle
handle?: string; handle?: string;
// class on resize-handle
reverse?: string; reverse?: string;
// class on resize-handle
vertical?: string; vertical?: string;
// class on container
resizing?: string; resizing?: string;
} }
@ -90,7 +81,7 @@ export default class Resizer<C extends IConfig = IConfig> {
Gives the distributor for a specific resize handle, as if you would have started Gives the distributor for a specific resize handle, as if you would have started
to drag that handle. Can be used to manipulate the size of an item programmatically. to drag that handle. Can be used to manipulate the size of an item programmatically.
@param {number} handleIndex the index of the resize handle in the container @param {number} handleIndex the index of the resize handle in the container
@return {Distributor} a new distributor for the given handle @return {FixedDistributor} a new distributor for the given handle
*/ */
public forHandleAt(handleIndex: number): FixedDistributor<C> { public forHandleAt(handleIndex: number): FixedDistributor<C> {
const handles = this.getResizeHandles(); const handles = this.getResizeHandles();
@ -121,7 +112,7 @@ export default class Resizer<C extends IConfig = IConfig> {
private onMouseDown = (event: MouseEvent) => { private onMouseDown = (event: MouseEvent) => {
// use closest in case the resize handle contains // use closest in case the resize handle contains
// child dom nodes that can be the target // child dom nodes that can be the target
const resizeHandle = event.target && (<HTMLElement>event.target).closest(`.${this.classNames.handle}`); const resizeHandle = event.target && (<HTMLDivElement>event.target).closest(`.${this.classNames.handle}`);
if (!resizeHandle || resizeHandle.parentElement !== this.container) { if (!resizeHandle || resizeHandle.parentElement !== this.container) {
return; return;
} }

View file

@ -1,5 +1,5 @@
/* /*
Copyright 2018 New Vector Ltd Copyright 2018 - 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.
@ -57,13 +57,13 @@ export default class Sizer {
} }
/** @return {number} container offset to document */ /** @return {number} container offset to document */
private getPageOffset() { private getPageOffset(): number {
let element = this.container; let element = this.container;
let offset = 0; let offset = 0;
while (element) { while (element) {
const pos = this.vertical ? element.offsetTop : element.offsetLeft; const pos = this.vertical ? element.offsetTop : element.offsetLeft;
offset = offset + pos; offset = offset + pos;
element = element.offsetParent as HTMLElement; element = <HTMLElement>element.offsetParent;
} }
return offset; return offset;
} }

View file

@ -6507,7 +6507,7 @@ mathml-tag-names@^2.0.1:
"matrix-js-sdk@github:matrix-org/matrix-js-sdk#develop": "matrix-js-sdk@github:matrix-org/matrix-js-sdk#develop":
version "8.5.0" version "8.5.0"
resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/d8c4101fdd521e189f4755c6f02a8971b991ef5f" resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/9f713781cdfea2349115ffaac2d665e8b07fd5dc"
dependencies: dependencies:
"@babel/runtime" "^7.11.2" "@babel/runtime" "^7.11.2"
another-json "^0.2.0" another-json "^0.2.0"