aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <542863+danfinlay@users.noreply.github.com>2018-06-15 00:49:38 +0800
committerGitHub <noreply@github.com>2018-06-15 00:49:38 +0800
commit3a5089da6faa35d6dc20dacbd87717e055a61a34 (patch)
tree3d55d150d69405b8c2d76ca9f3c4511626dbc5fb /app
parent1f83a110b959fcf9d8fa7cedb852f6c665bd0fc5 (diff)
parentc2afb7903522d87345f4a39f7ca3df8fa8889d53 (diff)
downloadtangerine-wallet-browser-3a5089da6faa35d6dc20dacbd87717e055a61a34.tar
tangerine-wallet-browser-3a5089da6faa35d6dc20dacbd87717e055a61a34.tar.gz
tangerine-wallet-browser-3a5089da6faa35d6dc20dacbd87717e055a61a34.tar.bz2
tangerine-wallet-browser-3a5089da6faa35d6dc20dacbd87717e055a61a34.tar.lz
tangerine-wallet-browser-3a5089da6faa35d6dc20dacbd87717e055a61a34.tar.xz
tangerine-wallet-browser-3a5089da6faa35d6dc20dacbd87717e055a61a34.tar.zst
tangerine-wallet-browser-3a5089da6faa35d6dc20dacbd87717e055a61a34.zip
Merge pull request #4566 from MetaMask/notice-phishing
Push new notice on recent phishing incidents
Diffstat (limited to 'app')
-rw-r--r--app/scripts/metamask-controller.js3
-rw-r--r--app/scripts/notice-controller.js32
2 files changed, 10 insertions, 25 deletions
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 14a63eae7..e202043cf 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 {
@@ -13,11 +13,12 @@ module.exports = class NoticeController extends EventEmitter {
this.firstVersion = opts.firstVersion
this.version = opts.version
const initState = extend({
- noticesList: [],
+ noticesList: this._filterNotices(hardCodedNotices),
}, opts.initState)
this.store = new ObservableStore(initState)
this.memStore = new ObservableStore({})
this.store.subscribe(() => this._updateMemstore())
+ this._updateMemstore()
}
getNoticesList () {
@@ -29,9 +30,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 +48,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 +65,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 +83,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 })
}
}