mirror of https://github.com/vector-im/riot-web
emit resize event when banners are shown/hidden to restore scroll pos
parent
af0a51d3b2
commit
4795625cee
|
@ -220,7 +220,17 @@ const Notifier = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
isToolbarHidden: function() {
|
shouldShowToolbar: function() {
|
||||||
|
const client = MatrixClientPeg.get();
|
||||||
|
if (!client) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const isGuest = client.isGuest();
|
||||||
|
return !isGuest && Notifier.supportsDesktopNotifications() &&
|
||||||
|
!Notifier.isEnabled() && !Notifier._isToolbarHidden();
|
||||||
|
},
|
||||||
|
|
||||||
|
_isToolbarHidden: function() {
|
||||||
// Check localStorage for any such meta data
|
// Check localStorage for any such meta data
|
||||||
if (global.localStorage) {
|
if (global.localStorage) {
|
||||||
return global.localStorage.getItem("notifications_hidden") === "true";
|
return global.localStorage.getItem("notifications_hidden") === "true";
|
||||||
|
|
|
@ -22,7 +22,6 @@ import PropTypes from 'prop-types';
|
||||||
import { DragDropContext } from 'react-beautiful-dnd';
|
import { DragDropContext } from 'react-beautiful-dnd';
|
||||||
|
|
||||||
import { KeyCode, isOnlyCtrlOrCmdKeyEvent } from '../../Keyboard';
|
import { KeyCode, isOnlyCtrlOrCmdKeyEvent } from '../../Keyboard';
|
||||||
import Notifier from '../../Notifier';
|
|
||||||
import PageTypes from '../../PageTypes';
|
import PageTypes from '../../PageTypes';
|
||||||
import CallMediaHandler from '../../CallMediaHandler';
|
import CallMediaHandler from '../../CallMediaHandler';
|
||||||
import sdk from '../../index';
|
import sdk from '../../index';
|
||||||
|
@ -121,6 +120,18 @@ const LoggedInView = React.createClass({
|
||||||
this._matrixClient.on("RoomState.events", this.onRoomStateEvents);
|
this._matrixClient.on("RoomState.events", this.onRoomStateEvents);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
// attempt to guess when a banner was opened or closed
|
||||||
|
if (
|
||||||
|
(prevProps.showCookieBar !== this.props.showCookieBar) ||
|
||||||
|
(prevProps.hasNewVersion !== this.props.hasNewVersion) ||
|
||||||
|
(prevProps.userHasGeneratedPassword !== this.props.userHasGeneratedPassword) ||
|
||||||
|
(prevProps.showNotifierToolbar !== this.props.showNotifierToolbar)
|
||||||
|
) {
|
||||||
|
this.props.resizeNotifier.notifyBannersChanged();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
document.removeEventListener('keydown', this._onKeyDown);
|
document.removeEventListener('keydown', this._onKeyDown);
|
||||||
this._matrixClient.removeListener("accountData", this.onAccountData);
|
this._matrixClient.removeListener("accountData", this.onAccountData);
|
||||||
|
@ -491,7 +502,6 @@ const LoggedInView = React.createClass({
|
||||||
});
|
});
|
||||||
|
|
||||||
let topBar;
|
let topBar;
|
||||||
const isGuest = this.props.matrixClient.isGuest();
|
|
||||||
if (this.state.syncErrorData && this.state.syncErrorData.error.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
|
if (this.state.syncErrorData && this.state.syncErrorData.error.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
|
||||||
topBar = <ServerLimitBar kind='hard'
|
topBar = <ServerLimitBar kind='hard'
|
||||||
adminContact={this.state.syncErrorData.error.data.admin_contact}
|
adminContact={this.state.syncErrorData.error.data.admin_contact}
|
||||||
|
@ -515,10 +525,7 @@ const LoggedInView = React.createClass({
|
||||||
topBar = <UpdateCheckBar {...this.props.checkingForUpdate} />;
|
topBar = <UpdateCheckBar {...this.props.checkingForUpdate} />;
|
||||||
} else if (this.state.userHasGeneratedPassword) {
|
} else if (this.state.userHasGeneratedPassword) {
|
||||||
topBar = <PasswordNagBar />;
|
topBar = <PasswordNagBar />;
|
||||||
} else if (
|
} else if (this.props.showNotifierToolbar) {
|
||||||
!isGuest && Notifier.supportsDesktopNotifications() &&
|
|
||||||
!Notifier.isEnabled() && !Notifier.isToolbarHidden()
|
|
||||||
) {
|
|
||||||
topBar = <MatrixToolbar />;
|
topBar = <MatrixToolbar />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import PlatformPeg from "../../PlatformPeg";
|
||||||
import SdkConfig from "../../SdkConfig";
|
import SdkConfig from "../../SdkConfig";
|
||||||
import * as RoomListSorter from "../../RoomListSorter";
|
import * as RoomListSorter from "../../RoomListSorter";
|
||||||
import dis from "../../dispatcher";
|
import dis from "../../dispatcher";
|
||||||
|
import Notifier from '../../Notifier';
|
||||||
|
|
||||||
import Modal from "../../Modal";
|
import Modal from "../../Modal";
|
||||||
import Tinter from "../../Tinter";
|
import Tinter from "../../Tinter";
|
||||||
|
@ -196,6 +197,7 @@ export default React.createClass({
|
||||||
|
|
||||||
syncError: null, // If the current syncing status is ERROR, the error object, otherwise null.
|
syncError: null, // If the current syncing status is ERROR, the error object, otherwise null.
|
||||||
resizeNotifier: new ResizeNotifier(),
|
resizeNotifier: new ResizeNotifier(),
|
||||||
|
showNotifierToolbar: Notifier.shouldShowToolbar(),
|
||||||
};
|
};
|
||||||
return s;
|
return s;
|
||||||
},
|
},
|
||||||
|
@ -644,8 +646,9 @@ export default React.createClass({
|
||||||
case 'view_invite':
|
case 'view_invite':
|
||||||
showRoomInviteDialog(payload.roomId);
|
showRoomInviteDialog(payload.roomId);
|
||||||
break;
|
break;
|
||||||
case 'notifier_enabled':
|
case 'notifier_enabled': {
|
||||||
this.forceUpdate();
|
this.setState({showNotifierToolbar: Notifier.shouldShowToolbar()});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'hide_left_panel':
|
case 'hide_left_panel':
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -1180,6 +1183,7 @@ export default React.createClass({
|
||||||
*/
|
*/
|
||||||
_onLoggedIn: async function() {
|
_onLoggedIn: async function() {
|
||||||
this.setStateForNewView({view: VIEWS.LOGGED_IN});
|
this.setStateForNewView({view: VIEWS.LOGGED_IN});
|
||||||
|
this.setState({showNotifierToolbar: Notifier.shouldShowToolbar()});
|
||||||
if (this._is_registered) {
|
if (this._is_registered) {
|
||||||
this._is_registered = false;
|
this._is_registered = false;
|
||||||
|
|
||||||
|
@ -1672,7 +1676,10 @@ export default React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_dispatchTimelineResize() {
|
_dispatchTimelineResize() {
|
||||||
|
// prevent dispatch from within dispatch error
|
||||||
|
setTimeout(() => {
|
||||||
dis.dispatch({ action: 'timeline_resize' }, true);
|
dis.dispatch({ action: 'timeline_resize' }, true);
|
||||||
|
}, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRoomCreated: function(roomId) {
|
onRoomCreated: function(roomId) {
|
||||||
|
|
Loading…
Reference in New Issue