aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/notice-controller.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-11-29 03:14:57 +0800
committerDan Finlay <dan@danfinlay.com>2017-11-29 03:14:57 +0800
commite89f82399f1c732c40dc644c496795833691cff0 (patch)
treee2d2490157ace55771dc59e8637143e544f80c30 /app/scripts/notice-controller.js
parent4d6bae774a22487f9861225e6fc00a73829a51ee (diff)
downloadtangerine-wallet-browser-e89f82399f1c732c40dc644c496795833691cff0.tar
tangerine-wallet-browser-e89f82399f1c732c40dc644c496795833691cff0.tar.gz
tangerine-wallet-browser-e89f82399f1c732c40dc644c496795833691cff0.tar.bz2
tangerine-wallet-browser-e89f82399f1c732c40dc644c496795833691cff0.tar.lz
tangerine-wallet-browser-e89f82399f1c732c40dc644c496795833691cff0.tar.xz
tangerine-wallet-browser-e89f82399f1c732c40dc644c496795833691cff0.tar.zst
tangerine-wallet-browser-e89f82399f1c732c40dc644c496795833691cff0.zip
Add optional version field to notices
Allows notices to only show to users who are on a certain version.
Diffstat (limited to 'app/scripts/notice-controller.js')
-rw-r--r--app/scripts/notice-controller.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js
index 57aad40c5..bc545127e 100644
--- a/app/scripts/notice-controller.js
+++ b/app/scripts/notice-controller.js
@@ -1,4 +1,5 @@
const EventEmitter = require('events').EventEmitter
+const semver = require('semver')
const extend = require('xtend')
const ObservableStore = require('obs-store')
const hardCodedNotices = require('../../notices/notices.json')
@@ -8,6 +9,7 @@ module.exports = class NoticeController extends EventEmitter {
constructor (opts) {
super()
this.noticePoller = null
+ this.version = opts.version
const initState = extend({
noticesList: [],
}, opts.initState)
@@ -51,7 +53,13 @@ module.exports = class NoticeController extends EventEmitter {
}
updateNoticesList () {
- return this._retrieveNoticeData().then((newNotices) => {
+ return this._retrieveNoticeData().then((hardNotices) => {
+ const newNotices = hardNotices.filter((newNotice) => {
+ if ('version' in newNotice) {
+ return semver.satisfies(this.version, newNotice.version)
+ }
+ return true
+ })
var oldNotices = this.getNoticesList()
var combinedNotices = this._mergeNotices(oldNotices, newNotices)
return Promise.resolve(this.setNoticesList(combinedNotices))