Skip to content

Commit 1a4edcb

Browse files
authored
runfix: do not overwrite service id when opening the service details (#17405)
* runfix: do not overwrite service id when opening the service details * refactor: open the right sidebar * runfix: is add mode * runfix: add missing default value
1 parent 5b8ae94 commit 1a4edcb

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/script/components/Conversation/Conversation.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,7 @@ export const Conversation = ({
254254

255255
const serviceEntity = userEntity.isService && (await repositories.integration.getServiceFromUser(userEntity));
256256

257-
if (serviceEntity) {
258-
openRightSidebar(panelId, {entity: {...serviceEntity, id: userEntity.id}}, true);
259-
} else {
260-
openRightSidebar(panelId, {entity: userEntity}, true);
261-
}
257+
openRightSidebar(panelId, {entity: serviceEntity || userEntity}, true);
262258
};
263259

264260
const showParticipants = (participants: User[]) => {

src/script/page/RightSidebar/RightSidebar.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ const RightSidebar: FC<RightSidebarProps> = ({
114114
const conversationState = container.resolve(ConversationState);
115115
const {activeConversation} = useKoSubscribableChildren(conversationState, ['activeConversation']);
116116

117-
const [isAddMode, setIsAddMode] = useState<boolean>(false);
118117
const [animatePanelToLeft, setAnimatePanelToLeft] = useState<boolean>(true);
119118

120119
const {rightSidebar} = useAppMainState.getState();
@@ -130,10 +129,9 @@ const RightSidebar: FC<RightSidebarProps> = ({
130129

131130
const closePanel = () => rightSidebar.close();
132131

133-
const togglePanel = (newState: PanelState, entity: PanelEntity | null, addMode: boolean = false) => {
132+
const togglePanel = (newState: PanelState, entity: PanelEntity | null, isAddMode: boolean = false) => {
134133
setAnimatePanelToLeft(true);
135-
rightSidebar.goTo(newState, {entity});
136-
setIsAddMode(addMode);
134+
rightSidebar.goTo(newState, {entity, isAddMode});
137135
};
138136

139137
const onBackClick = (entity: PanelEntity | null = activeConversation || null) => {
@@ -285,7 +283,7 @@ const RightSidebar: FC<RightSidebarProps> = ({
285283
onClose={closePanel}
286284
serviceEntity={serviceEntity}
287285
selfUser={selfUser}
288-
isAddMode={isAddMode}
286+
isAddMode={rightSidebar.isAddMode}
289287
/>
290288
)}
291289

src/script/page/state.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type RightSidebarParams = {
3333
entity: PanelEntity | null;
3434
showReactions?: boolean;
3535
highlighted?: User[];
36+
isAddMode?: boolean;
3637
};
3738

3839
type AppMainState = {
@@ -49,6 +50,7 @@ type AppMainState = {
4950
highlightedUsers: RightSidebarParams['highlighted'];
5051
history: PanelState[];
5152
showReactions: RightSidebarParams['showReactions'];
53+
isAddMode: RightSidebarParams['isAddMode'];
5254
lastViewedMessageDetailsEntity: Message | null;
5355
updateEntity: (entity: RightSidebarParams['entity']) => void;
5456
};
@@ -99,6 +101,7 @@ const useAppMainState = create<AppMainState>((set, get) => ({
99101
highlightedUsers: params?.highlighted || [],
100102
history: [...replacedNewState, panel],
101103
showReactions: !!params?.showReactions,
104+
isAddMode: !!params?.isAddMode,
102105
},
103106
};
104107
});
@@ -111,6 +114,7 @@ const useAppMainState = create<AppMainState>((set, get) => ({
111114
highlightedUsers: [],
112115
history: [],
113116
showReactions: false,
117+
isAddMode: false,
114118
updateEntity: (entity: RightSidebarParams['entity']) =>
115119
set(state => ({...state, rightSidebar: {...state.rightSidebar, entity}})),
116120
},

0 commit comments

Comments
 (0)