diff options
author | Thomas Huang <thomas.b.huang@gmail.com> | 2019-03-21 09:26:48 +0800 |
---|---|---|
committer | Thomas Huang <thomas.b.huang@gmail.com> | 2019-03-21 09:26:48 +0800 |
commit | c43374a553c28459be4cac116a72a4f34dddba72 (patch) | |
tree | e7584d60bf8617b742cdd09485f029e4d92f336d /app | |
parent | fc534b8041bbf69f3f7f8384554934d68a081835 (diff) | |
download | tangerine-wallet-browser-c43374a553c28459be4cac116a72a4f34dddba72.tar tangerine-wallet-browser-c43374a553c28459be4cac116a72a4f34dddba72.tar.gz tangerine-wallet-browser-c43374a553c28459be4cac116a72a4f34dddba72.tar.bz2 tangerine-wallet-browser-c43374a553c28459be4cac116a72a4f34dddba72.tar.lz tangerine-wallet-browser-c43374a553c28459be4cac116a72a4f34dddba72.tar.xz tangerine-wallet-browser-c43374a553c28459be4cac116a72a4f34dddba72.tar.zst tangerine-wallet-browser-c43374a553c28459be4cac116a72a4f34dddba72.zip |
Clear notices when setCompletedOnboarding is called
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/metamask-controller.js | 1 | ||||
-rw-r--r-- | app/scripts/notice-controller.js | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 540aee936..ce59caf83 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -473,6 +473,7 @@ module.exports = class MetamaskController extends EventEmitter { // notices checkNotices: noticeController.updateNoticesList.bind(noticeController), markNoticeRead: noticeController.markNoticeRead.bind(noticeController), + markAllNoticesRead: noticeController.markAllNoticesRead.bind(noticeController), approveProviderRequest: providerApprovalController.approveProviderRequest.bind(providerApprovalController), clearApprovedOrigins: providerApprovalController.clearApprovedOrigins.bind(providerApprovalController), diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js index 6fe8b8cf0..d1a15ff08 100644 --- a/app/scripts/notice-controller.js +++ b/app/scripts/notice-controller.js @@ -58,6 +58,23 @@ module.exports = class NoticeController extends EventEmitter { } } + markAllNoticesRead (cb) { + cb = cb || function (err) { if (err) throw err } + try { + const noticeList = this.getNoticesList() + noticeList.forEach(notice => { + notice.read = true + notice.body = '' + }) + this.setNoticesList(noticeList) + const latestNotice = this.getNextUnreadNotice() + cb(null, latestNotice) + } catch (err) { + cb(err) + } + } + + async updateNoticesList () { const newNotices = await this._retrieveNoticeData() const oldNotices = this.getNoticesList() |