From 19bd64978ddcb17bb77692cf7cc70555435e0d9d Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 16 Dec 2018 10:15:48 +0800 Subject: [PATCH 01/28] Add involved items subscription --- .eslintignore | 1 + package-lock.json | 213 +++++++++++++++++------- package.json | 2 + src/redux/sagas/handleReplyItem.html | 27 +++ src/redux/sagas/hashtag-saga.html | 53 ++++-- src/redux/sagas/notifications-saga.html | 83 ++------- src/redux/sagas/setup.html | 2 + src/redux/sagas/testingJsImports.js | 8 + test/toTest.test.js | 12 ++ 9 files changed, 266 insertions(+), 135 deletions(-) create mode 100644 src/redux/sagas/testingJsImports.js create mode 100644 test/toTest.test.js diff --git a/.eslintignore b/.eslintignore index ed78077c..4c423098 100755 --- a/.eslintignore +++ b/.eslintignore @@ -8,3 +8,4 @@ bower_components/** build/** webpack/** src/redux/** +test/** diff --git a/package-lock.json b/package-lock.json index a53c68e4..6c273e96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -257,7 +257,7 @@ }, "ansi-escapes": { "version": "3.1.0", - "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==", "dev": true }, @@ -374,7 +374,7 @@ }, "util": { "version": "0.10.3", - "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "requires": { "inherits": "2.0.1" @@ -1114,7 +1114,7 @@ }, "bl": { "version": "1.2.2", - "resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", "requires": { "readable-stream": "^2.3.5", @@ -1226,6 +1226,12 @@ "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, "browser-sync": { "version": "2.26.3", "resolved": "https://registry.npmjs.org/browser-sync/-/browser-sync-2.26.3.tgz", @@ -1624,7 +1630,7 @@ }, "browserify-aes": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "requires": { "buffer-xor": "^1.0.3", @@ -1658,7 +1664,7 @@ }, "browserify-rsa": { "version": "4.0.1", - "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "requires": { "bn.js": "^4.1.0", @@ -1788,7 +1794,7 @@ }, "cacache": { "version": "10.0.4", - "resolved": "http://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", "integrity": "sha512-Dph0MzuH+rTQzGPNT9fAnrPmMmjKfST6trxJeK7NQuHRaVw24VzPRWTmg9MpcwOVQZO0E1FBICUlFeNaKPIfHA==", "requires": { "bluebird": "^3.5.1", @@ -1839,7 +1845,7 @@ }, "callsites": { "version": "0.2.0", - "resolved": "http://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", "dev": true }, @@ -1962,7 +1968,7 @@ }, "class-is": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz", "integrity": "sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw==" }, "class-utils": { @@ -2216,7 +2222,7 @@ }, "create-hash": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "requires": { "cipher-base": "^1.0.1", @@ -2228,7 +2234,7 @@ }, "create-hmac": { "version": "1.1.7", - "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "requires": { "cipher-base": "^1.0.3", @@ -2393,12 +2399,12 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" }, "get-stream": { "version": "2.3.1", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", "requires": { "object-assign": "^4.0.1", @@ -2500,9 +2506,15 @@ "integrity": "sha1-p2o+0YVb56ASu4rBbLgPPADcKPA=", "dev": true }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, "diffie-hellman": { "version": "5.0.3", - "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "requires": { "bn.js": "^4.1.0", @@ -2537,7 +2549,7 @@ "dependencies": { "domelementtype": { "version": "1.1.3", - "resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", "dev": true } @@ -2555,7 +2567,7 @@ }, "domelementtype": { "version": "1.3.0", - "resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", "dev": true }, @@ -3325,7 +3337,7 @@ }, "events": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/events/-/events-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" }, "evp_bytestokey": { @@ -3663,7 +3675,7 @@ }, "finalhandler": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", "requires": { "debug": "2.6.9", @@ -4330,7 +4342,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "get-value": { @@ -4465,6 +4477,12 @@ "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=" }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, "gzip-size": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-5.0.0.tgz", @@ -4593,6 +4611,12 @@ "minimalistic-assert": "^1.0.1" } }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -4643,7 +4667,7 @@ }, "http-errors": { "version": "1.6.3", - "resolved": "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", "requires": { "depd": "~1.1.2", @@ -4946,7 +4970,7 @@ }, "ipfs-block": { "version": "0.7.1", - "resolved": "http://registry.npmjs.org/ipfs-block/-/ipfs-block-0.7.1.tgz", + "resolved": "https://registry.npmjs.org/ipfs-block/-/ipfs-block-0.7.1.tgz", "integrity": "sha512-ABZS9J/+OaDwc10zu6pIVdxWnOD/rkPEravk7FRVuRep7/zKSjffNhO/WuHN7Ex+MOBMz7mty0e+i6xjGnRsRQ==", "requires": { "cids": "^0.5.3", @@ -5032,7 +5056,7 @@ }, "is-builtin-module": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { @@ -5332,7 +5356,7 @@ }, "jsesc": { "version": "0.5.0", - "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true }, @@ -5372,12 +5396,12 @@ }, "json5": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" }, "jsonfile": { "version": "2.4.0", - "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "requires": { "graceful-fs": "^4.1.6" @@ -5444,7 +5468,7 @@ }, "libp2p-crypto": { "version": "0.13.0", - "resolved": "http://registry.npmjs.org/libp2p-crypto/-/libp2p-crypto-0.13.0.tgz", + "resolved": "https://registry.npmjs.org/libp2p-crypto/-/libp2p-crypto-0.13.0.tgz", "integrity": "sha512-i3r1TBec/xYmC5bcpPiIs3OyUAU3iy53OdRdxqawKoWTQPjYB+TyQ4w+otT66Y0sMcw70O0wH3GFAfPmQgFn+g==", "requires": { "asn1.js": "^5.0.0", @@ -5532,7 +5556,7 @@ }, "load-json-file": { "version": "2.0.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { @@ -5923,7 +5947,7 @@ }, "media-typer": { "version": "0.3.0", - "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" }, "mem": { @@ -6087,7 +6111,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" @@ -6101,6 +6125,65 @@ "mkdirp": "*" } }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + }, + "dependencies": { + "commander": { + "version": "2.15.1", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "mock-fs": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.7.0.tgz", @@ -6330,7 +6413,7 @@ "dependencies": { "buffer": { "version": "4.9.1", - "resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", "requires": { "base64-js": "^1.0.2", @@ -6584,7 +6667,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, @@ -6654,7 +6737,7 @@ }, "parse-asn1": { "version": "5.1.1", - "resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", "requires": { "asn1.js": "^4.0.0", @@ -6756,7 +6839,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-is-inside": { @@ -6843,7 +6926,7 @@ }, "libp2p-crypto": { "version": "0.12.1", - "resolved": "http://registry.npmjs.org/libp2p-crypto/-/libp2p-crypto-0.12.1.tgz", + "resolved": "https://registry.npmjs.org/libp2p-crypto/-/libp2p-crypto-0.12.1.tgz", "integrity": "sha512-1/z8rxZ0DcQNreZhEsl7PnLr7DWOioSvYbKBLGkRwNRiNh1JJLgh0PdTySBb44wkrOGT+TxcGRd7iq3/X6Wxwg==", "requires": { "asn1.js": "^5.0.0", @@ -6863,7 +6946,7 @@ }, "multiaddr": { "version": "4.0.0", - "resolved": "http://registry.npmjs.org/multiaddr/-/multiaddr-4.0.0.tgz", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-4.0.0.tgz", "integrity": "sha512-zUatrOCfBd/tJNOSoJ10d2EI2FDXB9PyPZhqUMdXE9mOyR3C+HLuOjga2Ga/eChwvEHIpTYRMoIKF2Nv7af2qQ==", "requires": { "bs58": "^4.0.1", @@ -6891,7 +6974,7 @@ }, "peer-id": { "version": "0.10.7", - "resolved": "http://registry.npmjs.org/peer-id/-/peer-id-0.10.7.tgz", + "resolved": "https://registry.npmjs.org/peer-id/-/peer-id-0.10.7.tgz", "integrity": "sha512-VEpMFcL9q0NQijmR0jsj38OGbY4yzaWMEareVkDahopmlNT+Cpsot8btPgsgBBApP9NiZj2Enwvh8rZN30ocQw==", "requires": { "async": "^2.6.0", @@ -11632,13 +11715,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -11655,19 +11740,22 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -11798,7 +11886,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -11812,6 +11901,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -11828,6 +11918,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -11836,13 +11927,15 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -11863,6 +11956,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -11951,7 +12045,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -11965,6 +12060,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -12102,6 +12198,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -19135,7 +19232,7 @@ }, "promise": { "version": "1.3.0", - "resolved": "http://registry.npmjs.org/promise/-/promise-1.3.0.tgz", + "resolved": "https://registry.npmjs.org/promise/-/promise-1.3.0.tgz", "integrity": "sha1-5cyaTIJ45GZP/twBx9qEhCsEAXU=", "requires": { "is-promise": "~1" @@ -19441,7 +19538,7 @@ }, "query-string": { "version": "5.1.1", - "resolved": "http://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", "requires": { "decode-uri-component": "^0.2.0", @@ -19539,7 +19636,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -19634,7 +19731,7 @@ }, "regjsgen": { "version": "0.2.0", - "resolved": "http://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=", "dev": true }, @@ -19701,7 +19798,7 @@ }, "require-uncached": { "version": "1.0.3", - "resolved": "http://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", "dev": true, "requires": { @@ -19862,7 +19959,7 @@ }, "safe-regex": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "requires": { "ret": "~0.1.10" @@ -19945,7 +20042,7 @@ "dependencies": { "commander": { "version": "2.8.1", - "resolved": "http://registry.npmjs.org/commander/-/commander-2.8.1.tgz", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", "requires": { "graceful-readlink": ">= 1.0.0" @@ -20070,7 +20167,7 @@ }, "sha.js": { "version": "2.4.11", - "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "requires": { "inherits": "^2.0.1", @@ -20547,7 +20644,7 @@ }, "stream-browserify": { "version": "2.0.1", - "resolved": "http://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", "requires": { "inherits": "~2.0.1", @@ -20650,7 +20747,7 @@ }, "strip-eof": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" }, "strip-hex-prefix": { @@ -20750,7 +20847,7 @@ }, "tar": { "version": "2.2.1", - "resolved": "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "requires": { "block-stream": "*", @@ -20786,7 +20883,7 @@ "dependencies": { "bluebird": { "version": "2.11.0", - "resolved": "http://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=" } } @@ -20867,7 +20964,7 @@ }, "through": { "version": "2.3.8", - "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "through2": { @@ -21116,7 +21213,7 @@ }, "buffer": { "version": "3.6.0", - "resolved": "http://registry.npmjs.org/buffer/-/buffer-3.6.0.tgz", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-3.6.0.tgz", "integrity": "sha1-pyyTb3e5a/UvX357RnGAYoVR3vs=", "requires": { "base64-js": "0.0.8", @@ -21285,7 +21382,7 @@ }, "utf8": { "version": "2.1.1", - "resolved": "http://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz", + "resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz", "integrity": "sha1-LgHbAvfY0JRPdxBPFgnrDDBM92g=" }, "util": { @@ -21857,7 +21954,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "requires": { "string-width": "^1.0.1", diff --git a/package.json b/package.json index 03a1665d..61c7ec92 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "eslint-plugin-html": "^4.0.5", "ethereumjs-tx": "^1.3.7", "ethereumjs-util": "^5.2.0", + "mocha": "^5.2.0", "moment": "^2.22.2", "polymer-cli": "^1.8.0", "qrcode": "^1.2.2", @@ -28,6 +29,7 @@ "lint": "npm run lint:javascript", "lint:javascript": "eslint . --ext js,html --ignore-path .eslintignore", "test": "polymer test", + "mocha": "mocha \"test/**/*.test.js\"", "test:integration": "polymer build # test that psk builds without error with the CLI", "build": "npm install && npm run webpack && node --max-old-space-size=8192 ./node_modules/.bin/polymer build", "build:nowp": "node --max-old-space-size=8192 ./node_modules/.bin/polymer build --verbose", diff --git a/src/redux/sagas/handleReplyItem.html b/src/redux/sagas/handleReplyItem.html index 535e359b..3d074f8b 100644 --- a/src/redux/sagas/handleReplyItem.html +++ b/src/redux/sagas/handleReplyItem.html @@ -74,11 +74,38 @@ } }) ]) + + // Notifications + // At this point all the item info is checked. + item = yield select(state => (state.hashtags[hashtagAddress] || {}).items[itemHash]); + // 1. Check if you are involved + if (yield call(youAreInvolvedInThisItem, item)) { + yield put({ type: "CHECK_INVOLVED_ITEM", newItem: item }); + } } catch (e) { console.error(`Error handling reply of itemHash: ${itemHash}`, e) } } + /** + * @param {Object} item must be an object with this properites: { + * numberOfReplies, + * providerAddress, + * status, + * seekerAddress, + * description, + * } + * @returns {Bool} true if you are involved in this item + */ + function* youAreInvolvedInThisItem(item) { + const yourAddress = yield select(selectors.address); + return ( + item.providerAddress === yourAddress || + item.seekerAddress === yourAddress || + (item.repliers || []).includes(yourAddress) + ) + } + function catIpfsMetadata(hash) { return ipfs.cat(hash).then(JSON.parse) } diff --git a/src/redux/sagas/hashtag-saga.html b/src/redux/sagas/hashtag-saga.html index a01fe228..a76c93dc 100644 --- a/src/redux/sagas/hashtag-saga.html +++ b/src/redux/sagas/hashtag-saga.html @@ -341,18 +341,32 @@ ) ); // At this point all the item info is checked. - item = yield select( - state => (state.hashtags[hashtagAddress] || {}).items[itemHash] - ); + item = yield select(state => (state.hashtags[hashtagAddress] || {}).items[itemHash]); + // 1. Check if a chat should be openned yield call(openChat, item); + // 2. Check if you are involved + if (yield call(youAreInvolvedInThisItem, item)) { + yield put({ type: "CHECK_INVOLVED_ITEM", newItem: item }); + } + } + + /** + * @param {Object} item must be an object with this properites: { + * numberOfReplies, + * providerAddress, + * status, + * seekerAddress, + * description, + * } + * @returns {Bool} true if you are involved in this item + */ + function* youAreInvolvedInThisItem(item) { const yourAddress = yield select(selectors.address); - if ( + return ( item.providerAddress === yourAddress || item.seekerAddress === yourAddress || (item.repliers || []).includes(yourAddress) - ) { - yield put({ type: "CHECK_INVOLVED_ITEM", newItem: item }); - } + ) } function* openChat({ @@ -467,7 +481,7 @@ // NewItem(owner, itemHash, itemMetadataHash, itemValue, hashtagFee, seekerRep) // Step 1. Store the item info console.log("Handling NewItem", event); - const item = { + let item = { blockNumber: event.blockNumber, hashtagFee: event.returnValues.hashtagFee, itemMetadataHash: event.returnValues.itemMetadataHash, @@ -481,10 +495,7 @@ yield put({ type: "UPDATE_ITEM", hashtagAddress, itemHash, data: item }); - // Step 2. Resolve its metadata - yield fork(getItemMetadata, item, hashtagAddress); - - // Step 3. Get the timestamp + // Step 2. Get the timestamp const timestamp = newEvent ? Math.floor(Date.now() / 1000) : yield call(getBlockTime, event.blockNumber); @@ -494,6 +505,17 @@ itemHash, data: { timestamp } }); + + // Step 3. Resolve its metadata + yield call(getItemMetadata, item, hashtagAddress); + + // Step 4. Notifications + // At this point all the item info is checked. + item = yield select(state => (state.hashtags[hashtagAddress] || {}).items[itemHash]); + // 1. Check if you are involved + if (yield call(youAreInvolvedInThisItem, item)) { + yield put({ type: "CHECK_INVOLVED_ITEM", newItem: item }); + } } function catIpfsMetadata(hash) { @@ -548,6 +570,13 @@ itemStatus: newstatus, providerAddress }); + + // At this point all the item info is checked. + item = yield select(state => (state.hashtags[hashtagAddress] || {}).items[itemHash]); + // 1. Check if you are involved + if (yield call(youAreInvolvedInThisItem, item)) { + yield put({ type: "CHECK_INVOLVED_ITEM", newItem: item }); + } } function* hashtagSubscription(hashtagAddress) { diff --git a/src/redux/sagas/notifications-saga.html b/src/redux/sagas/notifications-saga.html index 432fe834..e397d0e7 100644 --- a/src/redux/sagas/notifications-saga.html +++ b/src/redux/sagas/notifications-saga.html @@ -254,8 +254,14 @@ // involvedItemKeys = ['involvedItem-0x1234-0xabcd', 'involvedItem-0x2345-0xbcde'] const involvedItems = localDb.item.getAll() console.log(`Fetching new notifications of ${involvedItems.length} involved items`, { involvedItems }) + + // Step 2. For each item, call its contract to check the current state + // - readItemData() -> status, providerAddress, numberOfReplies + // If the state has changed, fire a notification and update the state const notificationsArray = yield all(involvedItems.map(item => call(function* () { try { + // Step 3. Open a subscription for that item + yield fork(itemSubscription, item.hashtagAddress, item.itemHash) return yield call(checkInvolvedItem, { item }) } catch (e) { console.error(`Error checking involved item ${item.hashtagAddress}/${item.itemHash}: ${e.stack}`) @@ -265,10 +271,6 @@ const notifications = notificationsArray.reduce((a, c) => [...a, ...c], []) console.log(`Fetched new notifications of involvedItemKeys`, notifications) - // Step 2. For each item, call its contract to check the current state - // - readItemData() -> status, providerAddress, numberOfReplies - - // Step 3. If the state has changed, fire a notification and update the state } catch (e) { console.error(`Error on startNotifications: ${e.message}`, e) } @@ -426,17 +428,16 @@ */ - function createHashtagSubscriptionChannel(hashtagAddress) { + function createItemSubscriptionChannel(hashtagAddress, itemHash) { const hashtagContract = new web3Local.eth.Contract(simpleDeal.abi, hashtagAddress); return eventChannel(emitter => { // Unique place to subscribe to all hashtag relevant events - // - NewItem(owner, itemHash, itemMetadataHash, itemValue, hashtagFee, seekerRep) // - ItemChange(indexed itemHash, newstatus, providerAddress) // - ReplyItem(indexed itemHash, replyMetadataHash, provider) // provider => providerAddress - const events = ['NewItem', 'ItemChange', 'ReplyItem'] + const events = ['ItemChange', 'ReplyItem'] const subscribeInstances = events.map(eventName => { try { - return hashtagContract.events[eventName]((err, event) => { + return hashtagContract.events[eventName]({ filter: itemHash }, (err, event) => { if (err) console.error('Error receiving event', err) else emitter(event) }) @@ -444,11 +445,6 @@ console.error('Error creating subscription to NewItem in ' + hashtagAddress) } }) - - window.addEventListener('cancel-sub', () => { - emitter(END) - }); - const unsubscribeFunction = () => { subscribeInstances.forEach(instance => { // Ensure that the instance exists @@ -463,68 +459,25 @@ }) } - function* handleNewItem(event, hashtagAddress, newEvent = false) { - // NewItem(owner, itemHash, itemMetadataHash, itemValue, hashtagFee, seekerRep) - // Step 1. Store the item info - console.log('Handling NewItem', event) - const item = { - blockNumber: event.blockNumber, - hashtagFee: event.returnValues.hashtagFee, - itemMetadataHash: event.returnValues.itemMetadataHash, - itemHash: event.returnValues.itemHash, - itemValue: event.returnValues.itemValue, - seekerAddress: event.returnValues.owner, // owner => seeker - seekerRep: event.returnValues.seekerRep, - status: 0, - } - const { itemHash, itemMetadataHash } = event.returnValues - yield put({ type: 'UPDATE_ITEM', hashtagAddress, itemHash, data: item }); - - // Step 2. Resolve its metadata - yield fork(getItemMetadata, item, hashtagAddress) - - // Step 3. Get the timestamp - const timestamp = newEvent - ? Math.floor(Date.now() / 1000) - : yield call(getBlockTime, event.blockNumber) - yield put({ type: 'UPDATE_ITEM', hashtagAddress, itemHash, data: { timestamp } }); - } - - function* handleItemChange(event, hashtagAddress) { - // ItemChange(indexed itemHash, newstatus, providerAddress) - // Step 1. Store the item info - console.log('Handling ItemChange', event) - const { itemHash, newstatus, providerAddress } = event.returnValues - - yield put({ - type: 'UPDATE_ITEM', hashtagAddress, itemHash, data: { - status: newstatus, - providerAddress, - } - }); - yield call(openChat, { hashtagAddress, itemHash, itemStatus: newstatus, providerAddress }) - } - - - function* hashtagSubscription(hashtagAddress) { + function* itemSubscription(hashtagAddress, itemHash) { try { - const hashtagSubscriptionChannel = yield call(createHashtagSubscriptionChannel, hashtagAddress) + const itemSubscriptionChannel = yield call(createItemSubscriptionChannel, hashtagAddress, itemHash) while (true) { // take(END) will cause the saga to terminate by jumping to the finally block - let event = yield take(hashtagSubscriptionChannel) + let event = yield take(itemSubscriptionChannel) // Unique place to subscribe to all hashtag relevant events - // - NewItem(owner, itemHash, itemMetadataHash, itemValue, hashtagFee, seekerRep) // - ItemChange(indexed itemHash, newstatus, providerAddress) // - ReplyItem(indexed itemHash, replyMetadataHash, provider) + function* handleItemEvent(item) { + const newItem = yield call(getNewItem, item) + yield call(checkInvolvedItem, { newItem }) + } switch (event.event) { - case 'NewItem': - yield fork(handleNewItem, event, hashtagAddress, true) - break; case 'ItemChange': - yield fork(handleItemChange, event, hashtagAddress) + yield fork(handleItemEvent, item) break; case 'ReplyItem': - yield fork(handleReplyItem, event, true) + yield fork(handleItemEvent, item) break; default: console.error('Received unknown event ' + event.event, event) diff --git a/src/redux/sagas/setup.html b/src/redux/sagas/setup.html index a8af1903..41b90079 100644 --- a/src/redux/sagas/setup.html +++ b/src/redux/sagas/setup.html @@ -6,6 +6,8 @@ + + \ No newline at end of file diff --git a/src/redux/sagas/hashtag-saga.html b/src/redux/sagas/hashtag-saga.html index 665d6ae6..f28c57e4 100644 --- a/src/redux/sagas/hashtag-saga.html +++ b/src/redux/sagas/hashtag-saga.html @@ -1,10 +1,8 @@ - - \ No newline at end of file diff --git a/src/redux/sagas/item-saga.html b/src/redux/sagas/item-saga.html index c5833edb..abfff493 100644 --- a/src/redux/sagas/item-saga.html +++ b/src/redux/sagas/item-saga.html @@ -12,7 +12,7 @@ const { kovSwtToken, hashtagList, simpleDeal } = contractsData; // Import methods - const { handleReplyItem } = window; + const { handleReplyItem } = window; // It is in ./hashtag-saga.html /** * Gets hashtag from the blockchain @@ -46,7 +46,7 @@ } function catIpfsMetadata(hash) { - return ipfs.cat(hash).then(JSON.parse) + return ipfs.cat(hash, { parseJson: true }) } function getPastReplies(hashtagContract, itemHash, fromBlock) { @@ -67,17 +67,14 @@ } function* getItem({ item: itemHash }) { - console.log('GET ITEM req', itemHash) - if (!itemHash || !itemHash.startsWith('0x')) { - return console.error(`itemHash is not correct, itemHash = ${itemHash}`) + console.log(`GET ITEM request for itemHash ${itemHash}`) + if (!itemHash) { + return console.error('Error: itemHash is not defined') } // Get current hashtag const hashtagAddress = yield select(state => state.current.hashtag) - const hashtagContract = new web3Local.eth.Contract( - simpleDeal.abi, - hashtagAddress - ); + const hashtagContract = new web3Local.eth.Contract(simpleDeal.abi, hashtagAddress); // Step 1. Call contract state: // Revelant props: @@ -94,7 +91,6 @@ call(function* () { try { const res = yield call(catIpfsMetadata, itemMetadataHash) - console.log(res) yield put(updateThisItem({ seekerAvatarHash: res.avatar || res.avatarHash, description: res.description, diff --git a/src/redux/sagas/local-db.html b/src/redux/sagas/local-db.html index eae7a6db..2ea88870 100644 --- a/src/redux/sagas/local-db.html +++ b/src/redux/sagas/local-db.html @@ -58,6 +58,28 @@ return JSON.parse(notification) } + function getBalance({ chain, token }) { + return localStorage.getItem(`balance-${token}-${chain}`) + } + function setBalance({ chain, token, balance }) { + localStorage.setItem(`balance-${token}-${chain}`, balance); + } + + // Chat + function setChat(itemHash, chatCache) { + const key = `chat-${itemHash}` + localStorage.setItem(key, JSON.stringify(chatCache)); + } + function getChat(itemHash) { + const key = `chat-${itemHash}` + const data = localStorage.getItem(key); + return JSON.parse(data) + } + function hasChat(itemHash) { + const key = `chat-${itemHash}` + return key in localStorage + } + // For testing window.removeAllInvolvedItems = (confirmation) => { if (confirmation !== 'I am sure') { @@ -77,6 +99,15 @@ .forEach(key => localStorage.removeItem(key)) return "Removed all notifications" } + window.removeAllBalances = (confirmation) => { + if (confirmation !== 'I am sure') { + return console.warn(`Running this function will erase all balances. If you know what you are doing run the function again with: \n removeAllNotifications('I am sure')`) + } + Object.keys(localStorage) + .filter(key => key.startsWith('balance-')) + .forEach(key => localStorage.removeItem(key)) + return "Removed all balances" + } // For testing window.localStorageSpace = () => { @@ -104,6 +135,15 @@ get: getNotification, set: setNotification, getAll: getAllNotifications + }, + balance: { + get: getBalance, + set: setBalance, + }, + chat: { + get: getChat, + set: setChat, + has: hasChat, } }; diff --git a/src/redux/sagas/notifications-saga.html b/src/redux/sagas/notifications-saga.html index 786b1a42..3ca314bc 100644 --- a/src/redux/sagas/notifications-saga.html +++ b/src/redux/sagas/notifications-saga.html @@ -1,5 +1,3 @@ - - \ No newline at end of file diff --git a/src/redux/sagas/item-saga.html b/src/redux/sagas/item-saga.html index abfff493..fbdaf2a3 100644 --- a/src/redux/sagas/item-saga.html +++ b/src/redux/sagas/item-saga.html @@ -1,5 +1,3 @@ - - + \ No newline at end of file diff --git a/src/pages/notifications/notifications-notification-archive.html b/src/pages/notifications/notifications-notification-archive.html new file mode 100644 index 00000000..fb9ec0aa --- /dev/null +++ b/src/pages/notifications/notifications-notification-archive.html @@ -0,0 +1,117 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/pages/notifications/notifications-notification.html b/src/pages/notifications/notifications-notification.html index a77d44fa..cc5b144e 100644 --- a/src/pages/notifications/notifications-notification.html +++ b/src/pages/notifications/notifications-notification.html @@ -5,6 +5,7 @@ --> + @@ -26,6 +27,11 @@ .vertical { width: 100%; + max-width: 232px; + } + + .container[wide-layout] .vertical { + max-width: 100%; } iron-image { @@ -81,7 +87,8 @@ background-color: var(--sc-blue); } -
+ +
diff --git a/src/pages/notifications/notifications-repeater.html b/src/pages/notifications/notifications-repeater.html index 7ffd5526..61197c60 100644 --- a/src/pages/notifications/notifications-repeater.html +++ b/src/pages/notifications/notifications-repeater.html @@ -8,6 +8,7 @@ + @@ -21,7 +22,6 @@ @apply --layout-vertical; background-image: var(--sc-bg); height: 100%; - min-height: 100vh; box-sizing: border-box; padding-top: 100px; } @@ -37,10 +37,22 @@ }
- @@ -65,10 +77,11 @@ return 'You have successfully restored your account.'; break; case 'balance-received': - return `You received ${notification.tokenAmount / 1e18} SWT from ${notification.senderAddress}` + return `You received ${(notification.tokenAmount / 1e18).toFixed(2)} SWT from + ${notification.senderAddress === '0x0000000000000000000000000000000000000000' ? 'Reserves' : notification.senderAddress}` break; case 'balance-update': - return `You received ${notification.balanceDifference / 1e18} SWT` + return `You received ${(notification.balanceDifference / 1e18).toFixed(2)} SWT` break; // case 'balance-update': // return `Your ${(notification.token || '').toUpperCase()} balance on ${notification.chain} changed by ${notification.balanceDifference}` @@ -96,7 +109,6 @@ break; case 'chat-message': return (notification.count > 1 ? `${notification.count} new chat messages` : 'A new chat message') + ` for "${notification.description}".`; - break; case 'chat-member': return (notification.count > 1 ? `${notification.count} new members were` : 'A new member was') + ' added to the chat.'; @@ -119,6 +131,7 @@ })); break; case 'balance-update': + case 'balance-received': this.dispatchEvent(new CustomEvent('wallet')); break; default: diff --git a/src/pages/notifications/notifications-router.html b/src/pages/notifications/notifications-router.html index e61598b6..3778c6be 100644 --- a/src/pages/notifications/notifications-router.html +++ b/src/pages/notifications/notifications-router.html @@ -11,6 +11,8 @@ + + @@ -18,11 +20,28 @@ - - + + + + + + + +