diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-03-25 05:03:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-25 05:03:54 +0800 |
commit | ae310ed006dce874cdb84ce985641a208e9c1b79 (patch) | |
tree | cff23fbc0363775743afa9a6b4a6f1c1868d34e8 | |
parent | c15dfccaa4770539152acdfb81d623f0569e2d51 (diff) | |
parent | c45ed395a69dd6a753976f4b612d40d0f3da8407 (diff) | |
download | tangerine-wallet-browser-ae310ed006dce874cdb84ce985641a208e9c1b79.tar tangerine-wallet-browser-ae310ed006dce874cdb84ce985641a208e9c1b79.tar.gz tangerine-wallet-browser-ae310ed006dce874cdb84ce985641a208e9c1b79.tar.bz2 tangerine-wallet-browser-ae310ed006dce874cdb84ce985641a208e9c1b79.tar.lz tangerine-wallet-browser-ae310ed006dce874cdb84ce985641a208e9c1b79.tar.xz tangerine-wallet-browser-ae310ed006dce874cdb84ce985641a208e9c1b79.tar.zst tangerine-wallet-browser-ae310ed006dce874cdb84ce985641a208e9c1b79.zip |
Merge branch 'master' into kovan-notice
-rw-r--r-- | app/scripts/migrations/012.js | 36 | ||||
-rw-r--r-- | app/scripts/notice-controller.js | 1 | ||||
-rw-r--r-- | test/lib/migrations/004.json | 7 | ||||
-rw-r--r-- | test/unit/migrations-test.js | 7 |
4 files changed, 51 insertions, 0 deletions
diff --git a/app/scripts/migrations/012.js b/app/scripts/migrations/012.js new file mode 100644 index 000000000..8361b3793 --- /dev/null +++ b/app/scripts/migrations/012.js @@ -0,0 +1,36 @@ +const version = 12 + +/* + +This migration modifies our notices to delete their body after being read. + +*/ + +const clone = require('clone') + +module.exports = { + version, + + migrate: function (originalVersionedData) { + let versionedData = clone(originalVersionedData) + versionedData.meta.version = version + try { + const state = versionedData.data + const newState = transformState(state) + versionedData.data = newState + } catch (err) { + console.warn(`MetaMask Migration #${version}` + err.stack) + } + return Promise.resolve(versionedData) + }, +} + +function transformState (state) { + const newState = state + newState.NoticeController.noticesList.forEach((notice) => { + if (notice.read) { + notice.body = '' + } + }) + return newState +} diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js index 0d72760fe..57aad40c5 100644 --- a/app/scripts/notice-controller.js +++ b/app/scripts/notice-controller.js @@ -41,6 +41,7 @@ module.exports = class NoticeController extends EventEmitter { var notices = this.getNoticesList() var index = notices.findIndex((currentNotice) => currentNotice.id === noticeToMark.id) notices[index].read = true + notices[index].body = '' this.setNoticesList(notices) const latestNotice = this.getLatestUnreadNotice() cb(null, latestNotice) diff --git a/test/lib/migrations/004.json b/test/lib/migrations/004.json index 0e2075c46..a6487c1e2 100644 --- a/test/lib/migrations/004.json +++ b/test/lib/migrations/004.json @@ -48,6 +48,13 @@ "title":"Ending Morden Support", "body":"Due to [recent events](https://blog.ethereum.org/2016/11/20/from-morden-to-ropsten/), MetaMask is now deprecating support for the Morden Test Network.\n\nUsers will still be able to access Morden through a locally hosted node, but we will no longer be providing hosted access to this network through [Infura](http://infura.io/).\n\nPlease use the new Ropsten Network as your new default test network.\n\nYou can fund your Ropsten account using the buy button on your account page.\n\nBest wishes!\nThe MetaMask Team\n\n", "id":0 + }, + { + "read":false, + "date":"Sat Dec 17 2016", + "title":"Keeping It Real", + "body":"nonempty", + "id":1 } ], "conversionRate":12.66441492, diff --git a/test/unit/migrations-test.js b/test/unit/migrations-test.js index d2a83be77..ccd1477b0 100644 --- a/test/unit/migrations-test.js +++ b/test/unit/migrations-test.js @@ -15,6 +15,8 @@ const migration8 = require(path.join('..', '..', 'app', 'scripts', 'migrations', const migration9 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '009')) const migration10 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '010')) const migration11 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '011')) +const migration12 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '012')) + const oldTestRpc = 'https://rawtestrpc.metamask.io/' const newTestRpc = 'https://testrpc.metamask.io/' @@ -91,6 +93,11 @@ describe('wallet1 is migrated successfully', () => { }).then((eleventhResult) => { assert.equal(eleventhResult.data.isDisclaimerConfirmed, null, 'isDisclaimerConfirmed should not exist') assert.equal(eleventhResult.data.TOSHash, null, 'TOSHash should not exist') + + return migration12.migrate(eleventhResult) + }).then((twelfthResult) => { + assert.equal(twelfthResult.data.NoticeController.noticesList[0].body, '', 'notices that have been read should have an empty body.') + assert.equal(twelfthResult.data.NoticeController.noticesList[1].body, 'nonempty', 'notices that have not been read should not have an empty body.') }) }) |