From 607922735686aedf3fdf091ea1296d425d1a6337 Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Wed, 30 Sep 2026 15:42:40 +0200 Subject: [PATCH] fix context bug --- dist/index.js | 17 ++-- dist/sw.js | 2 +- dist/version.txt | 2 +- src/ViewModel/Global/coreViewModel.ts | 7 +- src/ViewModel/Pages/messagePageViewModel.ts | 87 ++++++++++---------- src/ViewModel/Pages/settingsPageViewModel.ts | 6 ++ 6 files changed, 68 insertions(+), 53 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5fc11a7c..095294bd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1438,9 +1438,9 @@ let exitNext = false; while (this.contexts.length > 0) { const currentContext = this.context; - if (!currentContext) return; + if (!currentContext) break; const response = currentContext.handleContextClose(fromHistoryEvent); - if (response == false) return; + if (response == false) break; this.contextStack.delete(currentContext.contextId); if (response == true) { exitNext = true; @@ -4629,6 +4629,11 @@ this.secondaryChannels.add(secondaryChannel); } }; + // context + this.handleContextClose = (fromHistoryEvent) => { + if (!fromHistoryEvent) return; + return true; + }; this.preloadData(); this.cannotSetEncryptionKey = createProxyState( [this.encryptionKeyInput], @@ -4961,9 +4966,11 @@ }; // context this.handleContextClose = (fromHistoryEvent) => { - if (this.replyViewSelectedMessage.value == void 0 && fromHistoryEvent) return true; - this.resetReplyView(); - return false; + if (fromHistoryEvent) { + if (this.replyViewSelectedMessage.value == void 0) return true; + this.resetReplyView(); + return false; + } }; this.restoreFilter(); this.cannotSendMessage = createProxyState( diff --git a/dist/sw.js b/dist/sw.js index 4a349fc8..a0b43ab7 100644 --- a/dist/sw.js +++ b/dist/sw.js @@ -1,4 +1,4 @@ -const VERSION = "2610 Beta 21.9" +const VERSION = "2610 Beta 21.11" function processUrl(event) { const url = event.request.url; diff --git a/dist/version.txt b/dist/version.txt index cd1ac1bf..50679254 100644 --- a/dist/version.txt +++ b/dist/version.txt @@ -1 +1 @@ -2610 Beta 21.9 +2610 Beta 21.11 diff --git a/src/ViewModel/Global/coreViewModel.ts b/src/ViewModel/Global/coreViewModel.ts index 05091df7..8627615f 100644 --- a/src/ViewModel/Global/coreViewModel.ts +++ b/src/ViewModel/Global/coreViewModel.ts @@ -56,17 +56,16 @@ export default class CoreViewModel { while (this.contexts.length > 0) { const currentContext: Context | undefined = this.context; - if (!currentContext) return; + if (!currentContext) break; const response = currentContext.handleContextClose(fromHistoryEvent); - if (response == false) return; + if (response == false) break; this.contextStack.delete(currentContext.contextId); if (response == true) { exitNext = true; continue; } else if (exitNext == true) { break - } - else if (currentContext.contextId == contextId) { + } else if (currentContext.contextId == contextId) { break; } } diff --git a/src/ViewModel/Pages/messagePageViewModel.ts b/src/ViewModel/Pages/messagePageViewModel.ts index cdec1bd3..36892ed3 100644 --- a/src/ViewModel/Pages/messagePageViewModel.ts +++ b/src/ViewModel/Pages/messagePageViewModel.ts @@ -198,57 +198,60 @@ export default class MessagePageViewModel extends Context { // context handleContextClose = (fromHistoryEvent: boolean):boolean=> { - if (this.replyViewSelectedMessage.value == undefined && fromHistoryEvent) return true; - this.resetReplyView(); - return false; + if (fromHistoryEvent) { + if (this.replyViewSelectedMessage.value == undefined) return true; + + this.resetReplyView(); + return false; + } } // init constructor( - public readonly coreViewModel: CoreViewModel, - public readonly chatViewModel: ChatViewModel, - public readonly contactListViewModel: ContactListViewModel, + public readonly coreViewModel: CoreViewModel, + public readonly chatViewModel: ChatViewModel, + public readonly contactListViewModel: ContactListViewModel, ) { - super("message-page"); - this.restoreFilter(); + super("message-page"); + this.restoreFilter(); - // states - this.cannotSendMessage = React.createProxyState( - [ - this.chatViewModel.settingsViewModel.username, - this.composingMessage, - ], - () => - this.chatViewModel.settingsViewModel.username.value == "" || - this.composingMessage.value == "", - ); + // states + this.cannotSendMessage = React.createProxyState( + [ + this.chatViewModel.settingsViewModel.username, + this.composingMessage, + ], + () => + this.chatViewModel.settingsViewModel.username.value == "" || + this.composingMessage.value == "", + ); - this.searchViewModel = new SearchViewModel( - this.chatMessageViewModels, - this.filteredMessageViewModels, - (chatMessageViewModel) => [chatMessageViewModel.body.value], - new React.ListState(), - ); + this.searchViewModel = new SearchViewModel( + this.chatMessageViewModels, + this.filteredMessageViewModels, + (chatMessageViewModel) => [chatMessageViewModel.body.value], + new React.ListState(), + ); - this.isFilterActive = React.createProxyState( - [this.searchViewModel.appliedQuery, this.reactionFilter], - () => - this.searchViewModel.appliedQuery.value != "" || - this.reactionFilter.value != undefined, - ); + this.isFilterActive = React.createProxyState( + [this.searchViewModel.appliedQuery, this.reactionFilter], + () => + this.searchViewModel.appliedQuery.value != "" || + this.reactionFilter.value != undefined, + ); - // keystrokes - this.registerKeyStroke(CommonKeys.Filter, this.showFilterModal); - this.registerKeyStroke(CommonKeys.CloseOrCancel, () => { - if (this.isFilterModalOpen.value == true) { - this.hideFilterModal(); - } else { - this.replyingMessage.value = undefined; - } - }); - this.registerKeyStroke(CommonKeys.Reset, this.resetFilter); - this.registerKeyStroke(CommonKeys.Create, this.setFocus); + // keystrokes + this.registerKeyStroke(CommonKeys.Filter, this.showFilterModal); + this.registerKeyStroke(CommonKeys.CloseOrCancel, () => { + if (this.isFilterModalOpen.value == true) { + this.hideFilterModal(); + } else { + this.replyingMessage.value = undefined; + } + }); + this.registerKeyStroke(CommonKeys.Reset, this.resetFilter); + this.registerKeyStroke(CommonKeys.Create, this.setFocus); - this.chatViewModel.registerContext(ChatPageTypes.Messages, this); + this.chatViewModel.registerContext(ChatPageTypes.Messages, this); } } diff --git a/src/ViewModel/Pages/settingsPageViewModel.ts b/src/ViewModel/Pages/settingsPageViewModel.ts index 12eccd14..c957d69f 100644 --- a/src/ViewModel/Pages/settingsPageViewModel.ts +++ b/src/ViewModel/Pages/settingsPageViewModel.ts @@ -115,6 +115,12 @@ export default class SettingsPageViewModel extends Context { } }; + // context + handleContextClose = (fromHistoryEvent: boolean): void | boolean => { + if (!fromHistoryEvent) return; + return true; + } + // init constructor( public readonly coreViewModel: CoreViewModel,