Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit ee8a6b4

Browse files
committed
Merge branch 't3chguy/dpsah/6785' of https://github.com/matrix-org/matrix-react-sdk into t3chguy/dpsah/6785.1
� Conflicts: � src/components/structures/RoomView.tsx
2 parents 0b713c2 + 667c129 commit ee8a6b4

File tree

12 files changed

+86
-15
lines changed

12 files changed

+86
-15
lines changed

src/SlashCommands.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,19 @@ export const Commands = [
154154
},
155155
category: CommandCategories.messages,
156156
}),
157+
new Command({
158+
command: 'lenny',
159+
args: '<message>',
160+
description: _td('Prepends ( ͡° ͜ʖ ͡°) to a plain-text message'),
161+
runFn: function(roomId, args) {
162+
let message = '( ͡° ͜ʖ ͡°)';
163+
if (args) {
164+
message = message + ' ' + args;
165+
}
166+
return success(MatrixClientPeg.get().sendTextMessage(roomId, message));
167+
},
168+
category: CommandCategories.messages,
169+
}),
157170
new Command({
158171
command: 'plain',
159172
args: '<message>',

src/components/structures/GroupView.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ export default class GroupView extends React.Component {
13221322
</div>
13231323
<GroupHeaderButtons />
13241324
</div>
1325-
<MainSplit panel={rightPanel}>
1325+
<MainSplit panel={rightPanel} resizeNotifier={this.props.resizeNotifier}>
13261326
<AutoHideScrollbar className="mx_GroupView_body">
13271327
{ this._getMembershipSection() }
13281328
{ this._getGroupSection() }

src/components/structures/LoggedInView.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ class LoggedInView extends React.Component<IProps, IState> {
256256
window.localStorage.setItem("mx_lhs_size", '' + size);
257257
this.props.resizeNotifier.notifyLeftHandleResized();
258258
},
259+
onResizeStart: () => {
260+
this.props.resizeNotifier.startResizing();
261+
},
262+
onResizeStop: () => {
263+
this.props.resizeNotifier.stopResizing();
264+
},
259265
};
260266
const resizer = new Resizer(
261267
this._resizeContainer.current,
@@ -648,12 +654,13 @@ class LoggedInView extends React.Component<IProps, IState> {
648654
break;
649655

650656
case PageTypes.UserView:
651-
pageElement = <UserView userId={this.props.currentUserId} />;
657+
pageElement = <UserView userId={this.props.currentUserId} resizeNotifier={this.props.resizeNotifier} />;
652658
break;
653659
case PageTypes.GroupView:
654660
pageElement = <GroupView
655661
groupId={this.props.currentGroupId}
656662
isNew={this.props.currentGroupIsNew}
663+
resizeNotifier={this.props.resizeNotifier}
657664
/>;
658665
break;
659666
}

src/components/structures/MainSplit.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,18 @@ import React from 'react';
1919
import { Resizable } from 're-resizable';
2020

2121
export default class MainSplit extends React.Component {
22-
_onResized = (event, direction, refToElement, delta) => {
22+
_onResizeStart = () => {
23+
this.props.resizeNotifier.startResizing();
24+
};
25+
26+
_onResize = () => {
27+
this.props.resizeNotifier.notifyRightHandleResized();
28+
};
29+
30+
_onResizeStop = (event, direction, refToElement, delta) => {
31+
this.props.resizeNotifier.stopResizing();
2332
window.localStorage.setItem("mx_rhs_size", this._loadSidePanelSize().width + delta.width);
24-
}
33+
};
2534

2635
_loadSidePanelSize() {
2736
let rhsSize = parseInt(window.localStorage.getItem("mx_rhs_size"), 10);
@@ -58,7 +67,9 @@ export default class MainSplit extends React.Component {
5867
bottomLeft: false,
5968
topLeft: false,
6069
}}
61-
onResizeStop={this._onResized}
70+
onResizeStart={this._onResizeStart}
71+
onResize={this._onResize}
72+
onResizeStop={this._onResizeStop}
6273
className="mx_RightPanel_ResizeWrapper"
6374
handleClasses={{left: "mx_RightPanel_ResizeHandle"}}
6475
>

src/components/structures/RoomView.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,8 @@ export default class RoomView extends React.Component<IProps, IState> {
19411941
maxHeight={this.state.auxPanelMaxHeight}
19421942
showApps={this.state.showApps}
19431943
hideAppsDrawer={false}
1944+
onResize={this.onResize}
1945+
resizeNotifier={this.props.resizeNotifier}
19441946
>
19451947
{ aux }
19461948
</AuxPanel>
@@ -2146,10 +2148,7 @@ export default class RoomView extends React.Component<IProps, IState> {
21462148
onLeaveClick={(myMembership === "join") ? this.onLeaveClick : null}
21472149
e2eStatus={this.state.e2eStatus}
21482150
/>
2149-
<MainSplit
2150-
panel={rightPanel}
2151-
resizeNotifier={this.props.resizeNotifier}
2152-
>
2151+
<MainSplit panel={rightPanel} resizeNotifier={this.props.resizeNotifier}>
21532152
<div className={fadableSectionClasses}>
21542153
{auxPanel}
21552154
<div className={timelineClasses}>

src/components/structures/ScrollPanel.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export default class ScrollPanel extends React.Component {
163163
this._pendingFillRequests = {b: null, f: null};
164164

165165
if (this.props.resizeNotifier) {
166-
this.props.resizeNotifier.on("middlePanelResized", this.onResize);
166+
this.props.resizeNotifier.on("middlePanelResizedNoisy", this.onResize);
167167
}
168168

169169
this.resetScrollState();
@@ -193,11 +193,12 @@ export default class ScrollPanel extends React.Component {
193193
this.unmounted = true;
194194

195195
if (this.props.resizeNotifier) {
196-
this.props.resizeNotifier.removeListener("middlePanelResized", this.onResize);
196+
this.props.resizeNotifier.removeListener("middlePanelResizedNoisy", this.onResize);
197197
}
198198
}
199199

200200
onScroll = ev => {
201+
if (this.props.resizeNotifier.isResizing) return; // skip scroll events caused by resizing
201202
debuglog("onScroll", this._getScrollNode().scrollTop);
202203
this._scrollTimeout.restart();
203204
this._saveScrollState();
@@ -207,6 +208,7 @@ export default class ScrollPanel extends React.Component {
207208
};
208209

209210
onResize = () => {
211+
debuglog("onResize");
210212
this.checkScroll();
211213
// update preventShrinkingState if present
212214
if (this.preventShrinkingState) {
@@ -236,7 +238,6 @@ export default class ScrollPanel extends React.Component {
236238
// when scrolled all the way down. E.g. Chrome 72 on debian.
237239
// so check difference <= 1;
238240
return Math.abs(sn.scrollHeight - (sn.scrollTop + sn.clientHeight)) <= 1;
239-
240241
};
241242

242243
// returns the vertical height in the given direction that can be removed from

src/components/structures/UserView.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export default class UserView extends React.Component {
8080
const RightPanel = sdk.getComponent('structures.RightPanel');
8181
const MainSplit = sdk.getComponent('structures.MainSplit');
8282
const panel = <RightPanel user={this.state.member} />;
83-
return (<MainSplit panel={panel}><HomePage /></MainSplit>);
83+
return (<MainSplit panel={panel} resizeNotifier={this.props.resizeNotifier}>
84+
<HomePage />
85+
</MainSplit>);
8486
} else {
8587
return (<div />);
8688
}

src/components/views/rooms/AppsDrawer.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import AccessibleButton from '../elements/AccessibleButton';
3333
import {IntegrationManagers} from "../../../integrations/IntegrationManagers";
3434
import SettingsStore from "../../../settings/SettingsStore";
3535
import {useLocalStorageState} from "../../../hooks/useLocalStorageState";
36+
import ResizeNotifier from "../../../utils/ResizeNotifier";
3637

3738
// The maximum number of widgets that can be added in a room
3839
const MAX_WIDGETS = 2;
@@ -41,6 +42,7 @@ export default class AppsDrawer extends React.Component {
4142
static propTypes = {
4243
userId: PropTypes.string.isRequired,
4344
room: PropTypes.object.isRequired,
45+
resizeNotifier: PropTypes.instanceOf(ResizeNotifier).isRequired,
4446
showApps: PropTypes.bool, // Should apps be rendered
4547
hide: PropTypes.bool, // If rendered, should apps drawer be visible
4648
};
@@ -218,9 +220,10 @@ export default class AppsDrawer extends React.Component {
218220
<PersistentVResizer
219221
id={"apps-drawer_" + this.props.room.roomId}
220222
minHeight={100}
221-
maxHeight={this.props.maxHeight - 50}
223+
maxHeight={this.props.maxHeight ? this.props.maxHeight - 50 : undefined}
222224
handleClass="mx_AppsContainer_resizerHandle"
223225
className="mx_AppsContainer"
226+
resizeNotifier={this.props.resizeNotifier}
224227
>
225228
{ apps }
226229
{ spinner }
@@ -231,7 +234,16 @@ export default class AppsDrawer extends React.Component {
231234
}
232235
}
233236

234-
const PersistentVResizer = ({id, minHeight, maxHeight, className, handleWrapperClass, handleClass, children}) => {
237+
const PersistentVResizer = ({
238+
id,
239+
minHeight,
240+
maxHeight,
241+
className,
242+
handleWrapperClass,
243+
handleClass,
244+
resizeNotifier,
245+
children,
246+
}) => {
235247
const [height, setHeight] = useLocalStorageState("pvr_" + id, 100);
236248
const [resizing, setResizing] = useState(false);
237249

@@ -241,10 +253,15 @@ const PersistentVResizer = ({id, minHeight, maxHeight, className, handleWrapperC
241253
maxHeight={maxHeight}
242254
onResizeStart={() => {
243255
if (!resizing) setResizing(true);
256+
resizeNotifier.startResizing();
257+
}}
258+
onResize={() => {
259+
resizeNotifier.notifyTimelineHeightChanged();
244260
}}
245261
onResizeStop={(e, dir, ref, d) => {
246262
setHeight(height + d.height);
247263
if (resizing) setResizing(false);
264+
resizeNotifier.stopResizing();
248265
}}
249266
handleWrapperClass={handleWrapperClass}
250267
handleClasses={{bottom: handleClass}}

src/components/views/rooms/AuxPanel.js

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ export default class AuxPanel extends React.Component {
204204
maxHeight={this.props.maxHeight}
205205
showApps={this.props.showApps}
206206
hide={this.props.hideAppsDrawer}
207+
resizeNotifier={this.props.resizeNotifier}
207208
/>;
208209

209210
let stateViews = null;

src/i18n/strings/en_EN.json

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
"Command error": "Command error",
150150
"Usage": "Usage",
151151
"Prepends ¯\\_(ツ)_/¯ to a plain-text message": "Prepends ¯\\_(ツ)_/¯ to a plain-text message",
152+
"Prepends ( ͡° ͜ʖ ͡°) to a plain-text message": "Prepends ( ͡° ͜ʖ ͡°) to a plain-text message",
152153
"Sends a message as plain text, without interpreting it as markdown": "Sends a message as plain text, without interpreting it as markdown",
153154
"Sends a message as html, without interpreting it as markdown": "Sends a message as html, without interpreting it as markdown",
154155
"Searches DuckDuckGo for results": "Searches DuckDuckGo for results",

src/resizer/resizer.js

+6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ export default class Resizer {
105105
if (this.classNames.resizing) {
106106
this.container.classList.add(this.classNames.resizing);
107107
}
108+
if (this.config.onResizeStart) {
109+
this.config.onResizeStart();
110+
}
108111

109112
const {sizer, distributor} = this._createSizerAndDistributor(resizeHandle);
110113
distributor.start();
@@ -119,6 +122,9 @@ export default class Resizer {
119122
if (this.classNames.resizing) {
120123
this.container.classList.remove(this.classNames.resizing);
121124
}
125+
if (this.config.onResizeStop) {
126+
this.config.onResizeStop();
127+
}
122128
distributor.finish();
123129
body.removeEventListener("mouseup", finishResize, false);
124130
document.removeEventListener("mouseleave", finishResize, false);

src/utils/ResizeNotifier.js

+13
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ export default class ResizeNotifier extends EventEmitter {
3131
// with default options, will call fn once at first call, and then every x ms
3232
// if there was another call in that timespan
3333
this._throttledMiddlePanel = throttle(() => this.emit("middlePanelResized"), 200);
34+
this._isResizing = false;
35+
}
36+
37+
get isResizing() {
38+
return this._isResizing;
39+
}
40+
41+
startResizing() {
42+
this._isResizing = true;
43+
}
44+
45+
stopResizing() {
46+
this._isResizing = false;
3447
}
3548

3649
_noisyMiddlePanel() {

0 commit comments

Comments
 (0)