From c31a341f7cb8e7032ab80938db54754ce4f35b37 Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Fri, 21 Apr 2023 13:53:04 +0800 Subject: [PATCH] fix: fix close the error message Fix hide other action modal when close the error message at the right top of the page. Change-Id: I8bae11a51bec1eb2c7855ca56d10dc1deda9f503 --- src/layouts/Base/index.jsx | 4 +++- src/stores/root.js | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/layouts/Base/index.jsx b/src/layouts/Base/index.jsx index a671d51b..cc3ea362 100644 --- a/src/layouts/Base/index.jsx +++ b/src/layouts/Base/index.jsx @@ -66,7 +66,9 @@ export class BaseLayout extends Component { } get noticeCount() { - return this.rootStore.noticeCount; + return ( + this.rootStore.noticeCount - (this.rootStore.noticeCountWaitRemove || 0) + ); } get user() { diff --git a/src/stores/root.js b/src/stores/root.js index d17a153c..3ecf7ed2 100644 --- a/src/stores/root.js +++ b/src/stores/root.js @@ -66,6 +66,8 @@ export class RootStore { @observable noticeCount = 0; + noticeCountWaitRemove = 0; + @observable enableBilling = false; @@ -187,6 +189,7 @@ export class RootStore { this.hasAdminPageRole = false; this.version = ''; this.noticeCount = 0; + this.noticeCountWaitRemove = 0; this.goToLoginPage(); } @@ -238,12 +241,21 @@ export class RootStore { @action removeNoticeCount() { - this.noticeCount -= 1; + const elements = document.getElementsByClassName('ant-modal'); + // if there is an modal in the page, the notice count will be changed later, after no modal. + if (elements.length > 0) { + this.noticeCountWaitRemove += 1; + } else { + const noticeCount = this.noticeCount - 1 - this.noticeCountWaitRemove; + this.noticeCount = noticeCount < 0 ? 0 : noticeCount; + this.noticeCountWaitRemove = 0; + } } @action clearNoticeCount() { this.noticeCount = 0; + this.noticeCountWaitRemove = 0; } clearData() {