fix context bug
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user