From afc0a10b520c6305e57ab8a133147ba38ad2d0fa Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Thu, 11 Jul 2024 21:34:21 +0200 Subject: [PATCH] remember whether object view was open --- dist/index.js | 11 +++++------ src/Model/model.ts | 5 ++--- src/Tabs/messageTab.tsx | 6 +++--- src/Views/Chat/threadView.tsx | 4 ++-- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/dist/index.js b/dist/index.js index 2174bf9e..b374ef1f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1204,7 +1204,7 @@ var chats = new ListState(); var chatIds = restoreListState("chat-ids"); var selectedChat = new State(void 0); - var isShowingChatTools = new State(false); + var isShowingObjects = restoreState("showing-objects", false); var newChatName = new State(""); var cannotCreateChat = createProxyState( [newChatName], @@ -1216,7 +1216,6 @@ newChatName.value = ""; } function closeChatView() { - isShowingChatTools.value = false; selectedChat.value = void 0; document.getElementById("settings-tab")?.scrollIntoView(); } @@ -1226,7 +1225,7 @@ document.getElementById("message-tab")?.scrollIntoView(); } function toggleChatTools() { - isShowingChatTools.value = !isShowingChatTools.value; + isShowingObjects.value = !isShowingObjects.value; } chatIds.value.forEach((id) => chats.add(new Chat(id))); if (serverAddressInput.value != "" && didRequestConnection.value == true) { @@ -1660,7 +1659,7 @@ } chat.messages.handleAddition(scrollToBottomIfAppropriate); chat.outbox.handleAddition(scrollToBottomIfAppropriate); - isShowingChatTools.subscribe(() => scrollToBottom()); + isShowingObjects.subscribe(() => scrollToBottom()); setTimeout(() => scrollToBottom(), 50); return listWrapper; } @@ -1681,7 +1680,7 @@ { "aria-label": translation.showObjects, "on:click": toggleChatTools, - "toggle:selected": isShowingChatTools + "toggle:selected": isShowingObjects }, /* @__PURE__ */ createElement("span", { class: "icon" }, "deployed_code") ), /* @__PURE__ */ createElement( @@ -1701,7 +1700,7 @@ return /* @__PURE__ */ createElement( "article", { - "toggle:showingchattools": isShowingChatTools, + "toggle:showingchattools": isShowingObjects, id: "message-tab", "children:set": messageTabContent } diff --git a/src/Model/model.ts b/src/Model/model.ts index 44390876..c0f48240 100644 --- a/src/Model/model.ts +++ b/src/Model/model.ts @@ -162,7 +162,7 @@ export const chats = new React.ListState(); export const chatIds = React.restoreListState("chat-ids"); export const selectedChat = new React.State(undefined); -export const isShowingChatTools = new React.State(false); +export const isShowingObjects = React.restoreState("showing-objects", false); export const newChatName = new React.State(""); export const cannotCreateChat = React.createProxyState( @@ -178,7 +178,6 @@ export function createChat() { } export function closeChatView() { - isShowingChatTools.value = false; selectedChat.value = undefined; document.getElementById("settings-tab")?.scrollIntoView(); } @@ -190,7 +189,7 @@ export function selectChat(chat: Chat) { } export function toggleChatTools() { - isShowingChatTools.value = !isShowingChatTools.value; + isShowingObjects.value = !isShowingObjects.value; } chatIds.value.forEach((id) => chats.add(new Chat(id))); diff --git a/src/Tabs/messageTab.tsx b/src/Tabs/messageTab.tsx index 6fde89f5..c14d49a9 100644 --- a/src/Tabs/messageTab.tsx +++ b/src/Tabs/messageTab.tsx @@ -1,6 +1,6 @@ import * as React from "bloatless-react"; -import { closeChatView, isShowingChatTools, selectedChat, toggleChatTools } from "../Model/model"; +import { closeChatView, isShowingObjects, selectedChat, toggleChatTools } from "../Model/model"; import { ChatObjectView } from "../Views/Objects/chatObjectView"; import { ChatOptionModal } from "../Views/Chat/chatOptionModal"; @@ -37,7 +37,7 @@ export function MessageTab() { @@ -61,7 +61,7 @@ export function MessageTab() { return (
diff --git a/src/Views/Chat/threadView.tsx b/src/Views/Chat/threadView.tsx index 0c7ce983..baa9ba06 100644 --- a/src/Views/Chat/threadView.tsx +++ b/src/Views/Chat/threadView.tsx @@ -2,7 +2,7 @@ import * as React from "bloatless-react"; import { Chat, ChatMessage } from "../../Model/chatModel"; -import { isShowingChatTools } from "../../Model/model"; +import { isShowingObjects } from "../../Model/model"; import { translation } from "../../translations"; export function ThreadView(chat: Chat) { @@ -138,7 +138,7 @@ export function ThreadView(chat: Chat) { chat.messages.handleAddition(scrollToBottomIfAppropriate); chat.outbox.handleAddition(scrollToBottomIfAppropriate); - isShowingChatTools.subscribe(() => scrollToBottom()); + isShowingObjects.subscribe(() => scrollToBottom()); setTimeout(() => scrollToBottom(), 50); return listWrapper;