add message filter
This commit is contained in:
@@ -23,7 +23,9 @@ export default class ChatMessageViewModel {
|
||||
sentByUser: boolean;
|
||||
|
||||
allReactions = new React.MapState<ChatMessageReaction>();
|
||||
userReaction = new React.State<ReactionSymbols | string | undefined>(undefined);
|
||||
userReaction = new React.State<ReactionSymbols | string | undefined>(
|
||||
undefined,
|
||||
);
|
||||
reactionsThumbsUp = React.MapState<ChatMessageReaction>;
|
||||
reactionsCheck = React.MapState<ChatMessageReaction>;
|
||||
reactionsStop = React.MapState<ChatMessageReaction>;
|
||||
@@ -93,8 +95,11 @@ export default class ChatMessageViewModel {
|
||||
this.allReactions.set(reaction.sender, reaction);
|
||||
}
|
||||
|
||||
if (reaction.sender != this.coreViewModel.settingsModel.username) return;
|
||||
this.userReaction.value = reaction.isDeleting ? undefined : reaction.content;
|
||||
if (reaction.sender != this.coreViewModel.settingsModel.username)
|
||||
return;
|
||||
this.userReaction.value = reaction.isDeleting
|
||||
? undefined
|
||||
: reaction.content;
|
||||
};
|
||||
|
||||
sendReaction = (content: ReactionSymbols, isDeleting: boolean): void => {
|
||||
|
||||
@@ -8,11 +8,16 @@ import {
|
||||
import ChatMessageViewModel from "../Chat/chatMessageViewModel";
|
||||
import ChatViewModel from "../Chat/chatViewModel";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
import SearchViewModel from "../Utility/searchViewModel";
|
||||
|
||||
export default class MessagePageViewModel {
|
||||
// state
|
||||
chatMessageViewModels: React.MapState<ChatMessageViewModel> =
|
||||
new React.MapState();
|
||||
filteredMessageViewModels: React.ListState<ChatMessageViewModel> =
|
||||
new React.ListState();
|
||||
searchViewModel: SearchViewModel<ChatMessageViewModel>;
|
||||
isFilterModalOpen = new React.State<boolean>(false);
|
||||
composingMessage: React.State<string> = new React.State("");
|
||||
|
||||
// guards
|
||||
@@ -81,6 +86,10 @@ export default class MessagePageViewModel {
|
||||
messageViewModel.handleReaction(reaction);
|
||||
};
|
||||
|
||||
openFilterModal = (): void => {
|
||||
this.isFilterModalOpen.value = true;
|
||||
};
|
||||
|
||||
// load
|
||||
loadData = (): void => {
|
||||
this.chatMessageViewModels.clear();
|
||||
@@ -106,5 +115,12 @@ export default class MessagePageViewModel {
|
||||
this.chatViewModel.settingsViewModel.username.value == "" ||
|
||||
this.composingMessage.value == "",
|
||||
);
|
||||
|
||||
this.searchViewModel = new SearchViewModel(
|
||||
this.chatMessageViewModels,
|
||||
this.filteredMessageViewModels,
|
||||
(chatMessageViewModel) => [chatMessageViewModel.body.value],
|
||||
new React.ListState(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user