Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Close an unpinned notification tray when a new thread opens in the room on screen

AdityaUmale2cb90a8adf38
diff --git a/src/state/store.test.ts b/src/state/store.test.ts
index 69fb25abdf..342a73a3ba 100644
--- a/src/state/store.test.ts
+++ b/src/state/store.test.ts
@@ -3180,6 +3180,16 @@ describe("notifications feed", () => {
expect(reducer({ ...inRoom, notificationsPinned: true }, roomSwitch).notificationsOpen).toBe(true);
});
+ it("unpinned, a new thread in the room on screen closes it; a background room leaves it", () => {
+ const open = { ...reducer(initialState, { type: "toggleNotifications", open: true }), selectedId: "room-1",
+ groups: [{ id: "room-1", threadId: "room-t" }] as AppState["groups"] };
+ const action = { type: "newGroupTask", groupId: "room-1" } as const;
+ expect(reducer(open, action).notificationsOpen).toBe(false);
+ expect(reducer({ ...open, notificationsPinned: true }, action).notificationsOpen).toBe(true);
+ expect(reducer({ ...open, selectedId: "bot-1" }, action).notificationsOpen).toBe(true);
+ expect(reducer({ ...open, activeView: "team-map" as const }, action).notificationsOpen).toBe(true);
+ });
+
it("a thread switch in a room that is not on screen leaves the tray as it is", () => {
const open = { ...reducer(initialState, { type: "toggleNotifications", open: true }), selectedId: "bot-1",
groups: [{ id: "room-1", threadId: "room-t" }] as AppState["groups"] };
diff --git a/src/state/store.tsx b/src/state/store.tsx
index e6a8a53d18..b8bfed52cd 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -1728,8 +1728,9 @@ export function reducer(state: AppState, action: Action): AppState {
}
case "switchGroupTask":
return state.selectedId === action.groupId && state.activeView === "chat" ? closeTrayUnlessShown(state, action.groupId, action.threadId) : state;
- case "deleteTask":
case "newGroupTask":
+ return state.selectedId === action.groupId && state.activeView === "chat" ? closeUnpinnedTray(state) : state;
+ case "deleteTask":
case "deleteGroupTask":
case "regenerateTaskTitle":
return state;