aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/config-manager.js
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-12-08 06:34:15 +0800
committerDan Finlay <dan@danfinlay.com>2016-12-17 02:44:52 +0800
commit8819475a2ed2ee7c34e983ebb5ab12661be1a961 (patch)
tree6d410c35aca5bae541481d96cb492597d7470826 /app/scripts/lib/config-manager.js
parentd5569781ba2668df78ab7cf0f20ac93f84cafadb (diff)
downloadtangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar.gz
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar.bz2
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar.lz
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar.xz
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar.zst
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.zip
Add ability to show notices to user & get confirmation.
Implement generation of markdown for notice files. Create npm command. Enhance notice generation. Add test files to test multiple notices. Add basic markdown support to notices. Interval checks for updates. Add extensionizer and linker Add terms and conditions state file Add link support to disclaimer. Changelog addition.
Diffstat (limited to 'app/scripts/lib/config-manager.js')
-rw-r--r--app/scripts/lib/config-manager.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index b8ffb6991..b5e4995ad 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -2,6 +2,7 @@ const Migrator = require('pojo-migrator')
const MetamaskConfig = require('../config.js')
const migrations = require('./migrations')
const rp = require('request-promise')
+const notices = require('../../../development/notices.json')
const TESTNET_RPC = MetamaskConfig.network.testnet
const MAINNET_RPC = MetamaskConfig.network.mainnet
@@ -162,6 +163,69 @@ ConfigManager.prototype.setData = function (data) {
}
//
+// Notices
+//
+
+ConfigManager.prototype.getNoticesList = function () {
+ var data = this.getData()
+ if ('noticesList' in data) {
+ return data.noticesList
+ } else {
+ return []
+ }
+}
+
+ConfigManager.prototype.setNoticesList = function (list) {
+ var data = this.getData()
+ data.noticesList = list
+ this.setData(data)
+ return Promise.resolve(true)
+}
+
+ConfigManager.prototype.markNoticeRead = function (notice) {
+ var notices = this.getNoticesList()
+ var id = notice.id
+ notices[id].read = true
+ this.setNoticesList(notices)
+}
+
+ConfigManager.prototype.updateNoticesList = function () {
+ return this._retrieveNoticeData().then((newNotices) => {
+ var oldNotices = this.getNoticesList()
+ var combinedNotices = this._mergeNotices(oldNotices, newNotices)
+ return Promise.resolve(this.setNoticesList(combinedNotices))
+ })
+}
+
+ConfigManager.prototype.getLatestUnreadNotice = function () {
+ var notices = this.getNoticesList()
+ var filteredNotices = notices.filter((notice) => {
+ return notice.read === false
+ })
+ return filteredNotices[filteredNotices.length - 1]
+}
+
+ConfigManager.prototype._mergeNotices = function (oldNotices, newNotices) {
+ var noticeMap = this._mapNoticeIds(oldNotices)
+ newNotices.forEach((notice) => {
+ if (noticeMap.indexOf(notice.id) === -1) {
+ oldNotices.push(notice)
+ }
+ })
+ return oldNotices
+}
+
+ConfigManager.prototype._mapNoticeIds = function (notices) {
+ return notices.map((notice) => notice.id)
+}
+
+ConfigManager.prototype._retrieveNoticeData = function () {
+ // Placeholder for the API.
+ return Promise.resolve(notices)
+}
+
+
+//
// Tx
//