persist message filter

This commit is contained in:
marlon-erler
2026-09-24 02:16:07 +02:00
parent 8a1a51e6fe
commit 2db78717e5
+10 -6
View File
@@ -125,9 +125,9 @@ export default class MessagePageViewModel extends Context {
this.isFilterModalOpen.value = false; this.isFilterModalOpen.value = false;
}; };
revokeReactionFilter = (): void => { revokeReactionFilter = (persist: boolean = true): void => {
this.reactionFilter.value = undefined; this.reactionFilter.value = undefined;
this.chatViewModel.chatModel.storeFilter(""); if (persist) this.chatViewModel.chatModel.storeFilter("");
}; };
setReactionFilter = (content: ReactionSymbols): void => { setReactionFilter = (content: ReactionSymbols): void => {
@@ -142,13 +142,14 @@ export default class MessagePageViewModel extends Context {
setReplyView = (message: ChatMessageViewModel): void => { setReplyView = (message: ChatMessageViewModel): void => {
this.replyViewSelectedMessage.value = message; this.replyViewSelectedMessage.value = message;
this.revokeReactionFilter(); this.revokeReactionFilter(false);
this.setReply(message, false); this.setReply(message, false);
} }
resetReplyView = (): void => { resetReplyView = (): void => {
this.replyViewSelectedMessage.value = undefined; this.replyViewSelectedMessage.value = undefined;
this.resetReply(false); this.resetReply(false);
this.restoreFilter();
} }
setFocus = (): void => { setFocus = (): void => {
@@ -166,12 +167,18 @@ export default class MessagePageViewModel extends Context {
} }
}; };
restoreFilter = (): void => {
const previousFilter = this.chatViewModel.chatModel.getFilter() as any;
if (Object.values(ReactionSymbols).includes(previousFilter)) this.setReactionFilter(previousFilter);
}
// init // init
constructor( constructor(
public readonly coreViewModel: CoreViewModel, public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel, public readonly chatViewModel: ChatViewModel,
) { ) {
super("message-page"); super("message-page");
this.restoreFilter();
// states // states
this.cannotSendMessage = React.createProxyState( this.cannotSendMessage = React.createProxyState(
@@ -198,9 +205,6 @@ export default class MessagePageViewModel extends Context {
this.reactionFilter.value != undefined, this.reactionFilter.value != undefined,
); );
const previousFilter = this.chatViewModel.chatModel.getFilter() as any;
if (Object.values(ReactionSymbols).includes(previousFilter)) this.setReactionFilter(previousFilter);
// keystrokes // keystrokes
this.registerKeyStroke(CommonKeys.Filter, this.showFilterModal); this.registerKeyStroke(CommonKeys.Filter, this.showFilterModal);
this.registerKeyStroke(CommonKeys.CloseOrCancel, () => { this.registerKeyStroke(CommonKeys.CloseOrCancel, () => {