From ac8b56a00defff4cb44a6a34251a19d8ab6159b6 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 13 Jun 2018 22:56:46 -0700 Subject: notices - notices collection is now manually edited --- app/scripts/notice-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts') diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js index 14a63eae7..377ef5055 100644 --- a/app/scripts/notice-controller.js +++ b/app/scripts/notice-controller.js @@ -2,7 +2,7 @@ const EventEmitter = require('events').EventEmitter const semver = require('semver') const extend = require('xtend') const ObservableStore = require('obs-store') -const hardCodedNotices = require('../../notices/notices.json') +const hardCodedNotices = require('../../notices/notices.js') const uniqBy = require('lodash.uniqby') module.exports = class NoticeController extends EventEmitter { -- cgit v1.2.3 From 44a8e48a04ea69e1f8e530ae1bacf55890f8df98 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 13 Jun 2018 23:30:31 -0700 Subject: notices - replace getLatestNotice with getNextNotice --- app/scripts/metamask-controller.js | 3 --- app/scripts/notice-controller.js | 29 ++++++++--------------------- 2 files changed, 8 insertions(+), 24 deletions(-) (limited to 'app/scripts') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index e444180cc..cc02958b5 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -189,9 +189,6 @@ module.exports = class MetamaskController extends EventEmitter { version, firstVersion: initState.firstTimeInfo.version, }) - this.noticeController.updateNoticesList() - // to be uncommented when retrieving notices from a remote server. - // this.noticeController.startPolling() this.shapeshiftController = new ShapeShiftController({ initState: initState.ShapeShiftController, diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js index 377ef5055..635922104 100644 --- a/app/scripts/notice-controller.js +++ b/app/scripts/notice-controller.js @@ -13,7 +13,7 @@ module.exports = class NoticeController extends EventEmitter { this.firstVersion = opts.firstVersion this.version = opts.version const initState = extend({ - noticesList: [], + noticesList: hardCodedNotices, }, opts.initState) this.store = new ObservableStore(initState) this.memStore = new ObservableStore({}) @@ -29,9 +29,9 @@ module.exports = class NoticeController extends EventEmitter { return notices.filter((notice) => notice.read === false) } - getLatestUnreadNotice () { + getNextUnreadNotice () { const unreadNotices = this.getUnreadNotices() - return unreadNotices[unreadNotices.length - 1] + return unreadNotices[0] } async setNoticesList (noticesList) { @@ -47,7 +47,7 @@ module.exports = class NoticeController extends EventEmitter { notices[index].read = true notices[index].body = '' this.setNoticesList(notices) - const latestNotice = this.getLatestUnreadNotice() + const latestNotice = this.getNextUnreadNotice() cb(null, latestNotice) } catch (err) { cb(err) @@ -64,15 +64,6 @@ module.exports = class NoticeController extends EventEmitter { return result } - startPolling () { - if (this.noticePoller) { - clearInterval(this.noticePoller) - } - this.noticePoller = setInterval(() => { - this.noticeController.updateNoticesList() - }, 300000) - } - _mergeNotices (oldNotices, newNotices) { return uniqBy(oldNotices.concat(newNotices), 'id') } @@ -91,19 +82,15 @@ module.exports = class NoticeController extends EventEmitter { }) } - _mapNoticeIds (notices) { - return notices.map((notice) => notice.id) - } - async _retrieveNoticeData () { // Placeholder for the API. - return hardCodedNotices + return [] } _updateMemstore () { - const lastUnreadNotice = this.getLatestUnreadNotice() - const noActiveNotices = !lastUnreadNotice - this.memStore.updateState({ lastUnreadNotice, noActiveNotices }) + const nextUnreadNotice = this.getNextUnreadNotice() + const noActiveNotices = !nextUnreadNotice + this.memStore.updateState({ nextUnreadNotice, noActiveNotices }) } } -- cgit v1.2.3 From 4b8a4fd5fe5816dc5d748436b5b1cd9fe7d5bdea Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 13 Jun 2018 23:52:51 -0700 Subject: test - e2e - check for phishing warning --- app/scripts/notice-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts') diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js index 635922104..5cbc14c78 100644 --- a/app/scripts/notice-controller.js +++ b/app/scripts/notice-controller.js @@ -13,7 +13,7 @@ module.exports = class NoticeController extends EventEmitter { this.firstVersion = opts.firstVersion this.version = opts.version const initState = extend({ - noticesList: hardCodedNotices, + noticesList: this._filterNotices(hardCodedNotices), }, opts.initState) this.store = new ObservableStore(initState) this.memStore = new ObservableStore({}) -- cgit v1.2.3 From 722c5ae82153d2bcf3c34037e13d3d5f430920f2 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 14 Jun 2018 00:23:01 -0700 Subject: notice-controller - update memStore on boot --- app/scripts/notice-controller.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/scripts') diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js index 5cbc14c78..e202043cf 100644 --- a/app/scripts/notice-controller.js +++ b/app/scripts/notice-controller.js @@ -18,6 +18,7 @@ module.exports = class NoticeController extends EventEmitter { this.store = new ObservableStore(initState) this.memStore = new ObservableStore({}) this.store.subscribe(() => this._updateMemstore()) + this._updateMemstore() } getNoticesList () { -- cgit v1.2.3