diff --git a/res/css/structures/_LeftPanel.scss b/res/css/structures/_LeftPanel.scss index f663d5a70bb..4c8a978e516 100644 --- a/res/css/structures/_LeftPanel.scss +++ b/res/css/structures/_LeftPanel.scss @@ -23,20 +23,41 @@ $roomListCollapsedWidth: 68px; } } -.mx_LeftPanel_outerWrapper { +.mx_LeftPanel_wrapper { display: flex; - flex-direction: column; max-width: 50%; position: relative; // Contain the amount of layers rendered by constraining what actually needs re-layering via css contain: layout paint; -} -.mx_LeftPanel_wrapper { - display: flex; - flex-direction: row; - flex: 1; + &:has(.mx_LeftPanelLiveShareWarning) { + top: 10px; + } + + .mx_LeftPanelLiveShareWarning { + position: absolute; // sit in the padding the left panel will make for us + top: 0; + z-index: 10; // above backdrops + + // Fill the left panel + width: 100%; + box-sizing: border-box; + + padding: $spacing-4; + text-align: center; + + background-color: $accent; + color: #fff; + font-size: $font-10px; + } + + // Until we have `:has()` selectors... this will have to do + &.mx_LeftPanel_wrapperWithLocshare { + // Create a gap for the LiveShareWarning to sit. + // content height + padding top + padding bottom + padding-top: calc($font-10px + $spacing-4 + $spacing-4); + } .mx_LeftPanel_wrapper--user { background-color: $roomlist-bg-color; diff --git a/res/css/structures/_MatrixChat.scss b/res/css/structures/_MatrixChat.scss index d0ee7d92ebd..a95bfa9eb9f 100644 --- a/res/css/structures/_MatrixChat.scss +++ b/res/css/structures/_MatrixChat.scss @@ -63,7 +63,7 @@ limitations under the License. } /* not the left panel, and not the resize handle, so the roomview/groupview/... */ -.mx_MatrixChat > :not(.mx_LeftPanel):not(.mx_SpacePanel):not(.mx_ResizeHandle):not(.mx_LeftPanel_outerWrapper) { +.mx_MatrixChat > :not(.mx_LeftPanel):not(.mx_SpacePanel):not(.mx_ResizeHandle):not(.mx_LeftPanel_wrapper) { background-color: $background; flex: 1 1 0; diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index 5c147ec0ee5..ca480c5c29e 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -76,7 +76,9 @@ import { TimelineRenderingType } from "../../contexts/RoomContext"; import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts"; import { SwitchSpacePayload } from "../../dispatcher/payloads/SwitchSpacePayload"; import { IConfigOptions } from "../../IConfigOptions"; -import LeftPanelLiveShareWarning from '../views/beacon/LeftPanelLiveShareWarning'; +import { OwnBeaconStore, OwnBeaconStoreEvent } from "../../stores/OwnBeaconStore"; +import { _t } from "../../languageHandler"; +import { Icon as LiveLocationIcon } from "../../../res/img/location/live-location.svg"; // 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. @@ -121,6 +123,7 @@ interface IState { useCompactLayout: boolean; activeCalls: Array; backgroundImage?: string; + isSharingLiveLocation?: boolean; } /** @@ -195,6 +198,8 @@ class LoggedInView extends React.Component { this.resizer = this.createResizer(); this.resizer.attach(); + OwnBeaconStore.instance.on(OwnBeaconStoreEvent.LivenessChange, this.onBeaconUpdate); + OwnProfileStore.instance.on(UPDATE_EVENT, this.refreshBackgroundImage); this.loadResizerPreferences(); this.refreshBackgroundImage(); @@ -210,9 +215,16 @@ class LoggedInView extends React.Component { SettingsStore.unwatchSetting(this.layoutWatcherRef); SettingsStore.unwatchSetting(this.compactLayoutWatcherRef); SettingsStore.unwatchSetting(this.backgroundImageWatcherRef); + OwnBeaconStore.instance.off(OwnBeaconStoreEvent.LivenessChange, this.onBeaconUpdate); this.resizer.detach(); } + private onBeaconUpdate = () => { + this.setState({ + isSharingLiveLocation: OwnBeaconStore.instance.hasLiveBeacons(), + }); + }; + private onCallState = (): void => { const activeCalls = CallHandler.instance.getAllActiveCalls(); if (activeCalls === this.state.activeCalls) return; @@ -681,6 +693,7 @@ class LoggedInView extends React.Component { ); }); + const isMinimized = this.props.collapseLhs || false; return (
{ >
-
- -
- { SettingsStore.getValue('TagPanel.enableTagPanel') && +
+ { this.state.isSharingLiveLocation + ?
+ { isMinimized + ? + : _t('You are sharing your live location') + } +
: null + } + { SettingsStore.getValue('TagPanel.enableTagPanel') && (
{ { SettingsStore.getValue("feature_custom_tags") ? : null }
) - } - { SpaceStore.spacesEnabled ? <> - - - : null } + } + { SpaceStore.spacesEnabled ? <> -
- -
+ + : null } + +
+
diff --git a/src/components/views/beacon/LeftPanelLiveShareWarning.tsx b/src/components/views/beacon/LeftPanelLiveShareWarning.tsx deleted file mode 100644 index d0be4f087eb..00000000000 --- a/src/components/views/beacon/LeftPanelLiveShareWarning.tsx +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright 2022 The Matrix.org Foundation C.I.C. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import classNames from 'classnames'; -import React from 'react'; - -import { useEventEmitterState } from '../../../hooks/useEventEmitter'; -import { _t } from '../../../languageHandler'; -import { OwnBeaconStore, OwnBeaconStoreEvent } from '../../../stores/OwnBeaconStore'; -import { Icon as LiveLocationIcon } from '../../../../res/img/location/live-location.svg'; - -interface Props { - isMinimized?: boolean; -} - -const LeftPanelLiveShareWarning: React.FC = ({ isMinimized }) => { - const hasLiveBeacons = useEventEmitterState( - OwnBeaconStore.instance, - OwnBeaconStoreEvent.LivenessChange, - () => OwnBeaconStore.instance.hasLiveBeacons(), - ); - - if (!hasLiveBeacons) { - return null; - } - - return
- { isMinimized ? : _t('You are sharing your live location') } -
; -}; - -export default LeftPanelLiveShareWarning; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 08332fecdab..0758070df18 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2964,7 +2964,6 @@ "Beta": "Beta", "Leave the beta": "Leave the beta", "Join the beta": "Join the beta", - "You are sharing your live location": "You are sharing your live location", "Avatar": "Avatar", "This room is public": "This room is public", "Away": "Away", @@ -3084,6 +3083,7 @@ "Private community": "Private community", "To view %(communityName)s, swap to communities in your preferences": "To view %(communityName)s, swap to communities in your preferences", "To join %(communityName)s, swap to communities in your preferences": "To join %(communityName)s, swap to communities in your preferences", + "You are sharing your live location": "You are sharing your live location", "Wait!": "Wait!", "If someone told you to copy/paste something here, there is a high likelihood you're being scammed!": "If someone told you to copy/paste something here, there is a high likelihood you're being scammed!", "If you know what you're doing, Element is open-source, be sure to check out our GitHub (https://github.com/vector-im/element-web/) and contribute!": "If you know what you're doing, Element is open-source, be sure to check out our GitHub (https://github.com/vector-im/element-web/) and contribute!", diff --git a/test/components/views/beacon/LeftPanelLiveShareWarning-test.tsx b/test/components/views/beacon/LeftPanelLiveShareWarning-test.tsx index ed452281053..c2110f194ca 100644 --- a/test/components/views/beacon/LeftPanelLiveShareWarning-test.tsx +++ b/test/components/views/beacon/LeftPanelLiveShareWarning-test.tsx @@ -14,12 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -import React from 'react'; import { mocked } from 'jest-mock'; import { mount } from 'enzyme'; import '../../../skinned-sdk'; -import LeftPanelLiveShareWarning from '../../../../src/components/views/beacon/LeftPanelLiveShareWarning'; import { OwnBeaconStore, OwnBeaconStoreEvent } from '../../../../src/stores/OwnBeaconStore'; import { flushPromises } from '../../../test-utils'; @@ -39,10 +37,13 @@ jest.mock('../../../../src/stores/OwnBeaconStore', () => { }, ); -describe('', () => { - const defaultProps = {}; +// TODO: Restore component and re-enable test +// See https://github.com/vector-im/element-web/issues/21506 +describe.skip('', () => { const getComponent = (props = {}) => - mount(); + // TODO: Re-enable with above + //mount(); + mount(null); it('renders nothing when user has no live beacons', () => { const component = getComponent();