Tear down AppTile using lifecycle tracking (#7833)
This commit is contained in:
parent
f697301298
commit
a939184e10
8 changed files with 295 additions and 79 deletions
|
@ -31,7 +31,6 @@ import {
|
|||
convertToStorePanel,
|
||||
IRightPanelForRoom,
|
||||
} from './RightPanelStoreIPanelState';
|
||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
import RoomViewStore from '../RoomViewStore';
|
||||
|
||||
const GROUP_PHASES = [
|
||||
|
@ -71,7 +70,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
|
|||
protected async onReady(): Promise<any> {
|
||||
this.isReady = true;
|
||||
this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate);
|
||||
MatrixClientPeg.get().on("crypto.verification.request", this.onVerificationRequestUpdate);
|
||||
this.matrixClient.on("crypto.verification.request", this.onVerificationRequestUpdate);
|
||||
this.viewedRoomId = RoomViewStore.getRoomId();
|
||||
this.loadCacheFromSettings();
|
||||
this.emitAndUpdateSettings();
|
||||
|
@ -85,7 +84,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
|
|||
|
||||
protected async onNotReady(): Promise<any> {
|
||||
this.isReady = false;
|
||||
MatrixClientPeg.get().off("crypto.verification.request", this.onVerificationRequestUpdate);
|
||||
this.matrixClient.off("crypto.verification.request", this.onVerificationRequestUpdate);
|
||||
this.roomStoreToken.remove();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
* Copyright 2021 - 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.
|
||||
|
@ -28,8 +28,6 @@ import { SettingLevel } from "../../settings/SettingLevel";
|
|||
import { arrayFastClone } from "../../utils/arrays";
|
||||
import { UPDATE_EVENT } from "../AsyncStore";
|
||||
import { compare } from "../../utils/strings";
|
||||
import RightPanelStore from "../right-panel/RightPanelStore";
|
||||
import { RightPanelPhases } from "../right-panel/RightPanelStorePhases";
|
||||
|
||||
export const WIDGET_LAYOUT_EVENT_TYPE = "io.element.widgets.layout";
|
||||
|
||||
|
@ -354,22 +352,6 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
|||
return this.getContainerWidgets(room, container).some(w => w.id === widget.id);
|
||||
}
|
||||
|
||||
public isVisibleOnScreen(room: Optional<Room>, widgetId: string) {
|
||||
const wId = widgetId;
|
||||
const inRightPanel =
|
||||
(RightPanelStore.instance.currentCard.phase == RightPanelPhases.Widget &&
|
||||
wId == RightPanelStore.instance.currentCard.state?.widgetId);
|
||||
const inCenterContainer =
|
||||
this.getContainerWidgets(room, Container.Center).some((app) => app.id == wId);
|
||||
const inTopContainer =
|
||||
this.getContainerWidgets(room, Container.Top).some(app => app.id == wId);
|
||||
|
||||
// The widget should only be shown as a persistent app (in a floating pip container) if it is not visible on screen
|
||||
// either, because we are viewing a different room OR because it is in none of the possible containers of the room view.
|
||||
const isVisibleOnScreen = (inRightPanel || inCenterContainer || inTopContainer);
|
||||
return isVisibleOnScreen;
|
||||
}
|
||||
|
||||
public canAddToContainer(room: Room, container: Container): boolean {
|
||||
switch (container) {
|
||||
case Container.Top: return this.getContainerWidgets(room, container).length < MAX_PINNED;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue