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

Right panel store refactor #7313

Merged
merged 84 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
2575cb1
RightPanelStore getSharedInstance() > get instance
toger5 Dec 6, 2021
790e162
initial working refactor
toger5 Dec 8, 2021
cdb56d1
remove check right panel
toger5 Dec 8, 2021
b0c4558
change to fucntions instaed of actions
toger5 Dec 8, 2021
78f4e5e
refactor to readyWatchingStore
toger5 Dec 8, 2021
b4f1a95
using the new functions, fixing import cycle,
toger5 Dec 8, 2021
4f010e8
refactor toggle to RightPanelStore.togglePanel()
toger5 Dec 8, 2021
560585f
fix viewedRoomId undefined
toger5 Dec 8, 2021
88bf032
refactor SetRightPanelPhasePayload to IPanelState
toger5 Dec 8, 2021
094bf11
remove AfterRightPanelPhaseChangeAction
toger5 Dec 8, 2021
4620154
remove imports
toger5 Dec 8, 2021
3349076
Update typing and move RightPanelStore to folder
toger5 Dec 9, 2021
3bad57f
remove all the comments
toger5 Dec 9, 2021
1116c97
remove more commnets
toger5 Dec 9, 2021
766377f
fix loading and saving to device settings
toger5 Dec 9, 2021
0df5e63
Merge branch 'develop' into toger5/RightPanelStore_refactor
toger5 Dec 9, 2021
9ddf830
remove more comments
toger5 Dec 9, 2021
1522f85
rename thread realted properites for IPanelState
toger5 Dec 9, 2021
8e23f2e
remove more comments
toger5 Dec 9, 2021
213fc04
Merge branch 'develop' into toger5/RightPanelStore_refactor
toger5 Dec 10, 2021
8ea987b
fix saving with new thread event names
toger5 Dec 10, 2021
44e6e57
fix wrong this. (needed to use _this)
toger5 Dec 10, 2021
9071ee2
fix git ci
toger5 Dec 10, 2021
a9e9fbf
comment clean up
toger5 Dec 10, 2021
eab46c4
make the group stuff more compact
toger5 Dec 10, 2021
4cb7ed3
Merge branch 'develop' into toger5/RightPanelStore_refactor
toger5 Dec 13, 2021
0a209bc
fix import order
toger5 Dec 13, 2021
5839777
add console log
toger5 Dec 13, 2021
5a883cc
Merge branch 'develop' into toger5/RightPanelStore_refactor
toger5 Dec 13, 2021
49e89d0
rename room -> panel
toger5 Dec 13, 2021
0eff48e
Update src/components/structures/RightPanel.tsx
toger5 Dec 14, 2021
5f690a3
Update src/components/views/right_panel/HeaderButtons.tsx
toger5 Dec 14, 2021
7c82f8d
Update src/stores/right-panel/RightPanelStore.ts
toger5 Dec 14, 2021
726243a
Update src/stores/right-panel/RightPanelStore.ts
toger5 Dec 14, 2021
52d87c4
Update src/stores/right-panel/RightPanelStore.ts
toger5 Dec 14, 2021
cec0330
Update src/stores/right-panel/RightPanelStore.ts
toger5 Dec 14, 2021
125ff03
Update src/stores/right-panel/RightPanelStore.ts
toger5 Dec 14, 2021
97b2210
Update src/stores/right-panel/RightPanelStore.ts
toger5 Dec 14, 2021
ab32836
Update src/stores/right-panel/RightPanelStore.ts
toger5 Dec 14, 2021
ab6771a
Update src/stores/right-panel/RightPanelStore.ts
toger5 Dec 14, 2021
2ffb5b9
resolve review
toger5 Dec 14, 2021
a3f8ab6
Merge branch 'develop' into toger5/RightPanelStore_refactor
toger5 Dec 14, 2021
7301c64
remove comment (review)
toger5 Dec 14, 2021
2356c52
use default dispatcher
toger5 Dec 14, 2021
9be935f
check for dispatcherRef
toger5 Dec 14, 2021
c739f77
not unregisting dispatcher (for wrench test)
toger5 Dec 15, 2021
02ca999
unregister in destory
toger5 Dec 15, 2021
86bbb58
"react set state on unmounted" fixes
toger5 Dec 15, 2021
b8d0b7c
header button highlighting fix
toger5 Dec 15, 2021
3cfc79f
comments
toger5 Dec 15, 2021
715cf05
rename interfaces and function signatures:
toger5 Dec 15, 2021
5211c5f
another `unmounted` fix
toger5 Dec 15, 2021
64ddcea
add memberInfoEvent
toger5 Dec 15, 2021
8a2a3de
rightPanel state uses a cardState param
toger5 Dec 15, 2021
baf1471
fix displaying user in UserView
toger5 Dec 15, 2021
fc82e1e
fix error on close of overwrite card
toger5 Dec 15, 2021
a31196e
fix missing setRightPanel->setCard
toger5 Dec 15, 2021
bbf2415
Merge branch 'develop' into toger5/RightPanelStore_refactor
toger5 Dec 15, 2021
eea2af1
review fixes
toger5 Dec 15, 2021
0c63bdd
this.byRoom does not need to be set...
toger5 Dec 15, 2021
4dfdee9
some more cleanup
toger5 Dec 15, 2021
7ec26c4
Update src/stores/right-panel/RightPanelStoreIPanelState.ts
toger5 Dec 16, 2021
f6ae28b
Update src/stores/right-panel/RightPanelStoreIPanelState.ts
toger5 Dec 16, 2021
9f0383d
Update src/components/structures/UserView.tsx
toger5 Dec 16, 2021
8288bfb
Update src/components/structures/ThreadView.tsx
toger5 Dec 16, 2021
d2c0682
Update src/components/views/context_menus/RoomContextMenu.tsx
toger5 Dec 16, 2021
9192ec0
Update src/components/views/elements/MemberEventListSummary.tsx
toger5 Dec 16, 2021
7cdd1bc
Update src/components/views/right_panel/BaseCard.tsx
toger5 Dec 16, 2021
36b9bdd
rewrap try 2
toger5 Dec 16, 2021
bf97a40
Merge branch 'develop' into toger5/RightPanelStore_refactor
toger5 Dec 16, 2021
dad8ffd
fix saving space (now saves with only Id not space object)
toger5 Dec 16, 2021
a124133
fix toggling panel with setCard function
toger5 Dec 16, 2021
d709735
fix spaceId
toger5 Dec 16, 2021
57ee4d4
fix member stored as object (now using just id's)
toger5 Jan 4, 2022
c46615f
fix: loading veridication request from store
toger5 Jan 4, 2022
071983d
fix continuing verification request on site reload
toger5 Jan 4, 2022
dcfe2f6
linter
toger5 Jan 4, 2022
a90b783
Merge branch 'develop' into toger5/RightPanelStore_refactor
toger5 Jan 5, 2022
cfdbfbb
forward roomId in all cases
toger5 Jan 5, 2022
056c0d0
prevent toggle hack for e2e test
toger5 Jan 5, 2022
7b8c88f
linter
toger5 Jan 5, 2022
6f092c4
fix bind memory leak
toger5 Jan 5, 2022
606fb07
Update src/stores/right-panel/RightPanelStore.ts
toger5 Jan 5, 2022
146a8ef
semicolons
toger5 Jan 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/views/right_panel/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ const UserInfo: React.FC<IProps> = ({
previousPhase = RightPanelPhases.RoomMemberInfo;
cardState = { member };
} else if (room?.isSpaceRoom() && SpaceStore.spacesEnabled) {
previousPhase = previousPhase = RightPanelPhases.SpaceMemberList;
previousPhase = RightPanelPhases.SpaceMemberList;
cardState = { spaceId: room.roomId };
} else if (room) {
previousPhase = RightPanelPhases.RoomMemberList;
Expand Down
24 changes: 19 additions & 5 deletions src/stores/right-panel/RightPanelStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
IRightPanelForRoom,
convertCardToStore,
} from './RightPanelStoreIPanelState';
import { MatrixClientPeg } from "../../MatrixClientPeg";
// import RoomViewStore from '../RoomViewStore';

const GROUP_PHASES = [
Expand Down Expand Up @@ -77,6 +78,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
protected async onReady(): Promise<any> {
// TODO RightPanelStore (will be addressed when dropping groups): This should be used instead of the onDispatch callback when groups are removed.
// RoomViewStore.on(UPDATE_EVENT, this.onRoomViewStoreUpdate);
MatrixClientPeg.get().on("crypto.verification.request", this.onVerificationRequestUpdate.bind(this));
toger5 marked this conversation as resolved.
Show resolved Hide resolved
this.loadCacheFromSettings();
this.emitAndUpdateSettings();
}
Expand All @@ -91,6 +93,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
if (this.roomStoreToken) {
this.roomStoreToken.remove();
}
MatrixClientPeg.get().off("crypto.verification.request", this.onVerificationRequestUpdate.bind(this));
// TODO RightPanelStore (will be addressed when dropping groups): User this instead of the dispatcher.
// RoomViewStore.off(UPDATE_EVENT, this.onRoomViewStoreUpdate);
}
Expand Down Expand Up @@ -135,7 +138,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
public get previousGroup(): IRightPanelCard { return this.previousCard; }

// Setters
public setCard(card: IRightPanelCard, allowClose = true, roomId: string = null) {
public setCard(card: IRightPanelCard, allowClose = true, roomId?: string) {
const rId = roomId ?? this.viewedRoomId;
// this was previously a very multifunctional command:
// Toggle panel: if the same phase is send but without a state
Expand Down Expand Up @@ -166,7 +169,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
return;
} else if (targetPhase !== this.currentCard?.phase) {
// Set right panel and erase history.
this.setRightPanelCache({ phase: targetPhase, state: cardState ?? {} });
this.setRightPanelCache({ phase: targetPhase, state: cardState ?? {} }, rId);
}
}

Expand Down Expand Up @@ -223,9 +226,11 @@ export default class RightPanelStore extends ReadyWatchingStore {
if (!!room) {
this.global = this.global ??
convertToStatePanel(SettingsStore.getValue("RightPanel.phasesGlobal"), room);

this.byRoom[this.viewedRoomId] = this.byRoom[this.viewedRoomId] ??
convertToStatePanel(SettingsStore.getValue("RightPanel.phases", this.viewedRoomId), room);
} else {
console.warn("Could not restore the right panel after load, because there was no associated room object." +
"The right panel can only be restored, for rooms and spaces but not for groups");
toger5 marked this conversation as resolved.
Show resolved Hide resolved
}
}
toger5 marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -249,8 +254,8 @@ export default class RightPanelStore extends ReadyWatchingStore {
this.emit(UPDATE_EVENT, null);
}

private setRightPanelCache(card: IRightPanelCard) {
this.byRoom[this.viewedRoomId] = {
private setRightPanelCache(card: IRightPanelCard, roomId?: string) {
this.byRoom[roomId ?? this.viewedRoomId] = {
history: [{ phase: card.phase, state: card.state ?? {} }],
isOpen: true,
};
Expand Down Expand Up @@ -296,6 +301,15 @@ export default class RightPanelStore extends ReadyWatchingStore {
return true;
}
toger5 marked this conversation as resolved.
Show resolved Hide resolved

onVerificationRequestUpdate() {
const { member } = this.currentCard.state;
const pendingRequest = pendingVerificationRequestForUser(member);
if (pendingRequest) {
this.currentCard.state.verificationRequest = pendingRequest;
this.emitAndUpdateSettings();
}
}

onRoomViewStoreUpdate() {
// TODO: use this function instead of the onDispatch (the whole onDispatch can get removed!) as soon groups are removed
// this.viewedRoomId = RoomViewStore.getRoomId();
Expand Down
15 changes: 12 additions & 3 deletions src/stores/right-panel/RightPanelStoreIPanelState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ export interface IRightPanelCardState {
}

export interface IRightPanelCardStateStored {
member?: RoomMember | User | GroupMember;
verificationRequest?: VerificationRequest;
verificationRequestPromise?: Promise<VerificationRequest>;
memberId?: string;
// we do not store the things associated with verification
// group
groupId?: string;
groupRoomId?: string;
Expand Down Expand Up @@ -100,9 +99,15 @@ export function convertCardToStore(panelState: IRightPanelCard): IRightPanelCard
if (!!panelState?.state?.initialEvent?.getId()) {
panelStateThisRoomStored.initialEventId = panelState.state.initialEvent.getId();
}
if (!!panelState?.state?.member?.userId) {
panelStateThisRoomStored.memberId = panelState.state.member.userId;
}
delete panelStateThisRoomStored.threadHeadEvent;
delete panelStateThisRoomStored.initialEvent;
delete panelStateThisRoomStored.memberInfoEvent;
delete panelStateThisRoomStored.verificationRequest;
delete panelStateThisRoomStored.verificationRequestPromise;
delete panelStateThisRoomStored.member;

const storedCard = { state: panelStateThisRoomStored as IRightPanelCardStored, phase: panelState.phase };
return storedCard as IRightPanelCardStored;
toger5 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -119,9 +124,13 @@ function convertStoreToCard(panelStateStore: IRightPanelCardStored, room: Room):
if (!!panelStateThisRoom.initialEventId) {
panelStateThisRoom.initialEvent = room.findEventById(panelStateThisRoom.initialEventId);
}
if (!!panelStateThisRoom.memberId) {
panelStateThisRoom.member = room.getMember(panelStateThisRoom.memberId);
}
delete panelStateThisRoom.threadHeadEventId;
delete panelStateThisRoom.initialEventId;
delete panelStateThisRoom.memberInfoEventId;
delete panelStateThisRoom.memberId;

return { state: panelStateThisRoom as IRightPanelCardState, phase: panelStateStore.phase } as IRightPanelCard;
}