From f406feacc7a90e9ff5bd3c7c800fb772a44d9f05 Mon Sep 17 00:00:00 2001 From: janherich Date: Mon, 9 Apr 2018 09:59:45 +0200 Subject: [PATCH] Contact refactoring --- env/dev/env/config.cljs | 2 +- package-lock.json | 1098 ++++------------- package.json | 2 +- resources/default_contact_groups.json | 21 +- resources/default_contacts.json | 219 ++-- src/status_im/chat/console.cljs | 22 +- src/status_im/chat/events.cljs | 105 +- src/status_im/chat/models.cljs | 86 +- src/status_im/chat/models/commands.cljs | 5 +- src/status_im/chat/screen.cljs | 10 +- src/status_im/commands/events/loading.cljs | 34 +- src/status_im/commands/handlers/debug.cljs | 2 +- src/status_im/data_store/realm/chats.cljs | 42 +- .../data_store/realm/contact_groups.cljs | 20 +- .../realm/schemas/account/v1/chat.cljs | 5 +- .../schemas/account/v1/contact_group.cljs | 9 +- .../realm/schemas/account/v1/core.cljs | 4 - src/status_im/transport/handlers.cljs | 2 +- .../transport/message/v1/group_chat.cljs | 30 +- .../transport/message/v1/protocol.cljs | 10 +- src/status_im/transport/shh.cljs | 8 +- src/status_im/ui/screens/add_new/views.cljs | 12 +- src/status_im/ui/screens/contacts/events.cljs | 124 +- src/status_im/ui/screens/contacts/subs.cljs | 9 +- src/status_im/ui/screens/events.cljs | 4 +- .../screens/group/chat_settings/events.cljs | 7 +- src/status_im/ui/screens/group/core.cljs | 5 +- src/status_im/ui/screens/group/db.cljs | 8 +- src/status_im/ui/screens/group/events.cljs | 161 +-- .../ui/screens/profile/group_chat/views.cljs | 18 +- src/status_im/utils/contacts.cljs | 16 +- test/cljs/status_im/test/chat/events.cljs | 9 +- .../status_im/test/chat/models/input.cljs | 10 +- 33 files changed, 667 insertions(+), 1452 deletions(-) diff --git a/env/dev/env/config.cljs b/env/dev/env/config.cljs index e8c642bc44..7eb08b630f 100644 --- a/env/dev/env/config.cljs +++ b/env/dev/env/config.cljs @@ -3,4 +3,4 @@ (def figwheel-urls { :ios "ws://localhost:3449/figwheel-ws" :android "ws://10.0.2.2:3449/figwheel-ws" - }) \ No newline at end of file + }) diff --git a/package-lock.json b/package-lock.json index 553d7ca5cb..efe7a444bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1791,7 +1791,7 @@ }, "compression": { "version": "1.5.2", - "resolved": "http://registry.npmjs.org/compression/-/compression-1.5.2.tgz", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.5.2.tgz", "integrity": "sha1-sDuNhub4rSloPLqN+R3cb/x3s5U=", "requires": { "accepts": "1.2.13", @@ -2165,24 +2165,6 @@ "is-stream": "1.1.0" } }, - "decompress-tarxz": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/decompress-tarxz/-/decompress-tarxz-2.1.1.tgz", - "integrity": "sha512-U7LniyhLTpCc07lAmNXMX4NBW60ONkpGTwo6KxIDk9zk22GYh5NKjEI09F8I1oYkGr9WGOA6OH7scqLo7Xu5lA==", - "requires": { - "decompress-tar": "4.1.1", - "file-type": "3.9.0", - "is-stream": "1.1.0", - "lzma-native": "3.0.7" - }, - "dependencies": { - "file-type": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", - "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" - } - } - }, "decompress-unzip": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/decompress-unzip/-/decompress-unzip-4.0.1.tgz", @@ -3095,12 +3077,14 @@ "dependencies": { "abbrev": { "version": "1.1.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz", + "integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=", "optional": true }, "ajv": { "version": "4.11.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", "optional": true, "requires": { "co": "4.6.0", @@ -3109,16 +3093,19 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, "aproba": { "version": "1.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.1.1.tgz", + "integrity": "sha1-ldNgDwdxCqDpKYxyatXs8urLq6s=", "optional": true }, "are-we-there-yet": { "version": "1.1.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz", + "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", "optional": true, "requires": { "delegates": "1.0.0", @@ -3127,36 +3114,43 @@ }, "asn1": { "version": "0.2.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", "optional": true }, "assert-plus": { "version": "0.2.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", "optional": true }, "asynckit": { "version": "0.4.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "optional": true }, "aws-sign2": { "version": "0.6.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", "optional": true }, "aws4": { "version": "1.6.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", "optional": true }, "balanced-match": { "version": "0.4.2", - "bundled": true + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", + "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=" }, "bcrypt-pbkdf": { "version": "1.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", "optional": true, "requires": { "tweetnacl": "0.14.5" @@ -3164,21 +3158,24 @@ }, "block-stream": { "version": "0.0.9", - "bundled": true, + "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", + "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", "requires": { "inherits": "2.0.3" } }, "boom": { "version": "2.10.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "requires": { "hoek": "2.16.3" } }, "brace-expansion": { "version": "1.1.7", - "bundled": true, + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz", + "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=", "requires": { "balanced-match": "0.4.2", "concat-map": "0.0.1" @@ -3186,51 +3183,61 @@ }, "buffer-shims": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", + "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=" }, "caseless": { "version": "0.12.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", "optional": true }, "co": { "version": "4.6.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", "optional": true }, "code-point-at": { "version": "1.1.0", - "bundled": true + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, "combined-stream": { "version": "1.0.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", "requires": { "delayed-stream": "1.0.0" } }, "concat-map": { "version": "0.0.1", - "bundled": true + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, "core-util-is": { "version": "1.0.2", - "bundled": true + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "cryptiles": { "version": "2.0.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", "requires": { "boom": "2.10.1" } }, "dashdash": { "version": "1.14.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "optional": true, "requires": { "assert-plus": "1.0.0" @@ -3238,14 +3245,16 @@ "dependencies": { "assert-plus": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "optional": true } } }, "debug": { "version": "2.6.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", "optional": true, "requires": { "ms": "2.0.0" @@ -3253,26 +3262,31 @@ }, "deep-extend": { "version": "0.4.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", + "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", "optional": true }, "delayed-stream": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "delegates": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "optional": true }, "detect-libc": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.2.tgz", + "integrity": "sha1-ca1dIEvxempsqPRQxhRUBm70YeE=", "optional": true }, "ecc-jsbn": { "version": "0.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", "optional": true, "requires": { "jsbn": "0.1.1" @@ -3280,21 +3294,25 @@ }, "extend": { "version": "3.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", "optional": true }, "extsprintf": { "version": "1.0.2", - "bundled": true + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", + "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=" }, "forever-agent": { "version": "0.6.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", "optional": true }, "form-data": { "version": "2.1.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", "optional": true, "requires": { "asynckit": "0.4.0", @@ -3304,11 +3322,13 @@ }, "fs.realpath": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fstream": { "version": "1.0.11", - "bundled": true, + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", + "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", "requires": { "graceful-fs": "4.1.11", "inherits": "2.0.3", @@ -3318,7 +3338,8 @@ }, "fstream-ignore": { "version": "1.0.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz", + "integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=", "optional": true, "requires": { "fstream": "1.0.11", @@ -3328,7 +3349,8 @@ }, "gauge": { "version": "2.7.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "optional": true, "requires": { "aproba": "1.1.1", @@ -3343,7 +3365,8 @@ }, "getpass": { "version": "0.1.7", - "bundled": true, + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "optional": true, "requires": { "assert-plus": "1.0.0" @@ -3351,14 +3374,16 @@ "dependencies": { "assert-plus": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "optional": true } } }, "glob": { "version": "7.1.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "requires": { "fs.realpath": "1.0.0", "inflight": "1.0.6", @@ -3370,16 +3395,19 @@ }, "graceful-fs": { "version": "4.1.11", - "bundled": true + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" }, "har-schema": { "version": "1.0.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", + "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", "optional": true }, "har-validator": { "version": "4.2.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", + "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", "optional": true, "requires": { "ajv": "4.11.8", @@ -3388,12 +3416,14 @@ }, "has-unicode": { "version": "2.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", "optional": true }, "hawk": { "version": "3.1.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", "requires": { "boom": "2.10.1", "cryptiles": "2.0.5", @@ -3403,11 +3433,13 @@ }, "hoek": { "version": "2.16.3", - "bundled": true + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" }, "http-signature": { "version": "1.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", "optional": true, "requires": { "assert-plus": "0.2.0", @@ -3417,7 +3449,8 @@ }, "inflight": { "version": "1.0.6", - "bundled": true, + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "requires": { "once": "1.4.0", "wrappy": "1.0.2" @@ -3425,37 +3458,44 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "ini": { "version": "1.3.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", "optional": true }, "is-fullwidth-code-point": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "requires": { "number-is-nan": "1.0.1" } }, "is-typedarray": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "optional": true }, "isarray": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "isstream": { "version": "0.1.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "optional": true }, "jodid25519": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz", + "integrity": "sha1-BtSRIlUJNBlHfUJWM2BuDpB4KWc=", "optional": true, "requires": { "jsbn": "0.1.1" @@ -3463,17 +3503,20 @@ }, "jsbn": { "version": "0.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "optional": true }, "json-schema": { "version": "0.2.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", "optional": true }, "json-stable-stringify": { "version": "1.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "optional": true, "requires": { "jsonify": "0.0.0" @@ -3481,17 +3524,20 @@ }, "json-stringify-safe": { "version": "5.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "optional": true }, "jsonify": { "version": "0.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "optional": true }, "jsprim": { "version": "1.4.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", + "integrity": "sha1-o7h+QCmNjDgFUtjMdiigu5WiKRg=", "optional": true, "requires": { "assert-plus": "1.0.0", @@ -3502,48 +3548,56 @@ "dependencies": { "assert-plus": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "optional": true } } }, "mime-db": { "version": "1.27.0", - "bundled": true + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", + "integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=" }, "mime-types": { "version": "2.1.15", - "bundled": true, + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", + "integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=", "requires": { "mime-db": "1.27.0" } }, "minimatch": { "version": "3.0.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "requires": { "brace-expansion": "1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, "mkdirp": { "version": "0.5.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" } }, "ms": { "version": "2.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "optional": true }, "node-pre-gyp": { "version": "0.6.39", - "bundled": true, + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz", + "integrity": "sha512-OsJV74qxnvz/AMGgcfZoDaeDXKD3oY3QVIbBmwszTFkRisTSXbMQyn4UWzUMOtA5SVhrBZOTp0wcoSBgfMfMmQ==", "optional": true, "requires": { "detect-libc": "1.0.2", @@ -3561,7 +3615,8 @@ }, "nopt": { "version": "4.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "optional": true, "requires": { "abbrev": "1.1.0", @@ -3570,7 +3625,8 @@ }, "npmlog": { "version": "4.1.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.0.tgz", + "integrity": "sha512-ocolIkZYZt8UveuiDS0yAkkIjid1o7lPG8cYm05yNYzBn8ykQtaiPMEGp8fY9tKdDgm8okpdKzkvu1y9hUYugA==", "optional": true, "requires": { "are-we-there-yet": "1.1.4", @@ -3581,38 +3637,45 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, "oauth-sign": { "version": "0.8.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", "optional": true }, "object-assign": { "version": "4.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "optional": true }, "once": { "version": "1.4.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "requires": { "wrappy": "1.0.2" } }, "os-homedir": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "optional": true }, "os-tmpdir": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "optional": true }, "osenv": { "version": "0.1.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz", + "integrity": "sha1-Qv5tWVPfBsgGS+bxdsPQWqqjRkQ=", "optional": true, "requires": { "os-homedir": "1.0.2", @@ -3621,30 +3684,36 @@ }, "path-is-absolute": { "version": "1.0.1", - "bundled": true + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "performance-now": { "version": "0.2.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", + "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", "optional": true }, "process-nextick-args": { "version": "1.0.7", - "bundled": true + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" }, "punycode": { "version": "1.4.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", "optional": true }, "qs": { "version": "6.4.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", "optional": true }, "rc": { "version": "1.2.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.1.tgz", + "integrity": "sha1-LgPo5C7kULjLPc5lvhv4l04d/ZU=", "optional": true, "requires": { "deep-extend": "0.4.2", @@ -3655,14 +3724,16 @@ "dependencies": { "minimist": { "version": "1.2.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "optional": true } } }, "readable-stream": { "version": "2.2.9", - "bundled": true, + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.9.tgz", + "integrity": "sha1-z3jsb0ptHrQ9JkiMrJfwQudLf8g=", "requires": { "buffer-shims": "1.0.0", "core-util-is": "1.0.2", @@ -3675,7 +3746,8 @@ }, "request": { "version": "2.81.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", + "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", "optional": true, "requires": { "aws-sign2": "0.6.0", @@ -3704,40 +3776,47 @@ }, "rimraf": { "version": "2.6.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", + "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", "requires": { "glob": "7.1.2" } }, "safe-buffer": { "version": "5.0.1", - "bundled": true + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", + "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=" }, "semver": { "version": "5.3.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "optional": true }, "set-blocking": { "version": "2.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "optional": true }, "signal-exit": { "version": "3.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "optional": true }, "sntp": { "version": "1.0.9", - "bundled": true, + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", "requires": { "hoek": "2.16.3" } }, "sshpk": { "version": "1.13.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.0.tgz", + "integrity": "sha1-/yo+T9BEl1Vf7Zezmg/YL6+zozw=", "optional": true, "requires": { "asn1": "0.2.3", @@ -3753,14 +3832,16 @@ "dependencies": { "assert-plus": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "optional": true } } }, "string-width": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "requires": { "code-point-at": "1.1.0", "is-fullwidth-code-point": "1.0.0", @@ -3769,31 +3850,36 @@ }, "string_decoder": { "version": "1.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz", + "integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=", "requires": { "safe-buffer": "5.0.1" } }, "stringstream": { "version": "0.0.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", "optional": true }, "strip-ansi": { "version": "3.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "2.1.1" } }, "strip-json-comments": { "version": "2.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "optional": true }, "tar": { "version": "2.2.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "requires": { "block-stream": "0.0.9", "fstream": "1.0.11", @@ -3802,7 +3888,8 @@ }, "tar-pack": { "version": "3.4.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.4.0.tgz", + "integrity": "sha1-I74tf2cagzk3bL2wuP4/3r8xeYQ=", "optional": true, "requires": { "debug": "2.6.8", @@ -3817,7 +3904,8 @@ }, "tough-cookie": { "version": "2.3.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", + "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", "optional": true, "requires": { "punycode": "1.4.1" @@ -3825,7 +3913,8 @@ }, "tunnel-agent": { "version": "0.6.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "optional": true, "requires": { "safe-buffer": "5.0.1" @@ -3833,26 +3922,31 @@ }, "tweetnacl": { "version": "0.14.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "optional": true }, "uid-number": { "version": "0.0.6", - "bundled": true, + "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", + "integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=", "optional": true }, "util-deprecate": { "version": "1.0.2", - "bundled": true + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { "version": "3.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz", + "integrity": "sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE=", "optional": true }, "verror": { "version": "1.3.6", - "bundled": true, + "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", + "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=", "optional": true, "requires": { "extsprintf": "1.0.2" @@ -3860,7 +3954,8 @@ }, "wide-align": { "version": "1.1.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", + "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", "optional": true, "requires": { "string-width": "1.0.2" @@ -3868,7 +3963,8 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" } } }, @@ -5267,725 +5363,6 @@ "resolved": "https://registry.npmjs.org/ltgt/-/ltgt-2.2.1.tgz", "integrity": "sha1-81ypHEk/e3PaDgdJUwTxezH4fuU=" }, - "lzma-native": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/lzma-native/-/lzma-native-3.0.7.tgz", - "integrity": "sha512-gi3oEkvbrMk7Z8iAymzLGOmNxqxuyGaBXEMSOJFTmGxSibVk6VqcrutbLY3KKM6aBmqiL7lQfRl0PJxnhIfdRg==", - "requires": { - "nan": "2.10.0", - "node-pre-gyp": "0.6.39", - "readable-stream": "2.3.5", - "rimraf": "2.6.2" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true - }, - "ajv": { - "version": "4.11.8", - "bundled": true, - "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" - } - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true - }, - "are-we-there-yet": { - "version": "1.1.4", - "bundled": true, - "requires": { - "delegates": "1.0.0", - "readable-stream": "2.3.5" - } - }, - "asn1": { - "version": "0.2.3", - "bundled": true - }, - "assert-plus": { - "version": "0.2.0", - "bundled": true - }, - "asynckit": { - "version": "0.4.0", - "bundled": true - }, - "aws-sign2": { - "version": "0.6.0", - "bundled": true - }, - "aws4": { - "version": "1.6.0", - "bundled": true - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "bundled": true, - "optional": true, - "requires": { - "tweetnacl": "0.14.5" - } - }, - "block-stream": { - "version": "0.0.9", - "bundled": true, - "requires": { - "inherits": "2.0.3" - } - }, - "boom": { - "version": "2.10.1", - "bundled": true, - "requires": { - "hoek": "2.16.3" - } - }, - "brace-expansion": { - "version": "1.1.8", - "bundled": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "0.0.1" - } - }, - "caseless": { - "version": "0.12.0", - "bundled": true - }, - "co": { - "version": "4.6.0", - "bundled": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true - }, - "combined-stream": { - "version": "1.0.5", - "bundled": true, - "requires": { - "delayed-stream": "1.0.0" - } - }, - "concat-map": { - "version": "0.0.1", - "bundled": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true - }, - "cryptiles": { - "version": "2.0.5", - "bundled": true, - "requires": { - "boom": "2.10.1" - } - }, - "dashdash": { - "version": "1.14.1", - "bundled": true, - "requires": { - "assert-plus": "1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true - } - } - }, - "debug": { - "version": "2.6.9", - "bundled": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-extend": { - "version": "0.4.2", - "bundled": true - }, - "delayed-stream": { - "version": "1.0.0", - "bundled": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true - }, - "detect-libc": { - "version": "1.0.3", - "bundled": true - }, - "ecc-jsbn": { - "version": "0.1.1", - "bundled": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "extend": { - "version": "3.0.1", - "bundled": true - }, - "extsprintf": { - "version": "1.3.0", - "bundled": true - }, - "forever-agent": { - "version": "0.6.1", - "bundled": true - }, - "form-data": { - "version": "2.1.4", - "bundled": true, - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true - }, - "fstream": { - "version": "1.0.11", - "bundled": true, - "requires": { - "graceful-fs": "4.1.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.6.2" - } - }, - "fstream-ignore": { - "version": "1.0.5", - "bundled": true, - "requires": { - "fstream": "1.0.11", - "inherits": "2.0.3", - "minimatch": "3.0.4" - } - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "requires": { - "aproba": "1.2.0", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" - } - }, - "getpass": { - "version": "0.1.7", - "bundled": true, - "requires": { - "assert-plus": "1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true - } - } - }, - "glob": { - "version": "7.1.2", - "bundled": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "graceful-fs": { - "version": "4.1.11", - "bundled": true - }, - "har-schema": { - "version": "1.0.5", - "bundled": true - }, - "har-validator": { - "version": "4.2.1", - "bundled": true, - "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true - }, - "hawk": { - "version": "3.1.3", - "bundled": true, - "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" - } - }, - "hoek": { - "version": "2.16.3", - "bundled": true - }, - "http-signature": { - "version": "1.1.1", - "bundled": true, - "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.1", - "sshpk": "1.13.1" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true - }, - "ini": { - "version": "1.3.5", - "bundled": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "is-typedarray": { - "version": "1.0.0", - "bundled": true - }, - "isarray": { - "version": "1.0.0", - "bundled": true - }, - "isstream": { - "version": "0.1.2", - "bundled": true - }, - "jsbn": { - "version": "0.1.1", - "bundled": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "bundled": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "bundled": true, - "requires": { - "jsonify": "0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "bundled": true - }, - "jsonify": { - "version": "0.0.0", - "bundled": true - }, - "jsprim": { - "version": "1.4.1", - "bundled": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true - } - } - }, - "mime-db": { - "version": "1.30.0", - "bundled": true - }, - "mime-types": { - "version": "2.1.17", - "bundled": true, - "requires": { - "mime-db": "1.30.0" - } - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "requires": { - "brace-expansion": "1.1.8" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true - }, - "node-pre-gyp": { - "version": "0.6.39", - "bundled": true, - "requires": { - "detect-libc": "1.0.3", - "hawk": "3.1.3", - "mkdirp": "0.5.1", - "nopt": "4.0.1", - "npmlog": "4.1.2", - "rc": "1.2.6", - "request": "2.81.0", - "rimraf": "2.6.2", - "semver": "5.5.0", - "tar": "2.2.1", - "tar-pack": "3.4.1" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "requires": { - "abbrev": "1.1.1", - "osenv": "0.1.5" - } - }, - "npmlog": { - "version": "4.1.2", - "bundled": true, - "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true - }, - "oauth-sign": { - "version": "0.8.2", - "bundled": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true - }, - "osenv": { - "version": "0.1.5", - "bundled": true, - "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true - }, - "performance-now": { - "version": "0.2.0", - "bundled": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true - }, - "punycode": { - "version": "1.4.1", - "bundled": true - }, - "qs": { - "version": "6.4.0", - "bundled": true - }, - "rc": { - "version": "1.2.6", - "bundled": true, - "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.5", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true - } - } - }, - "readable-stream": { - "version": "2.3.5", - "bundled": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "request": { - "version": "2.81.0", - "bundled": true, - "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.1.0" - } - }, - "rimraf": { - "version": "2.6.2", - "bundled": true, - "requires": { - "glob": "7.1.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "bundled": true - }, - "semver": { - "version": "5.5.0", - "bundled": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true - }, - "sntp": { - "version": "1.0.9", - "bundled": true, - "requires": { - "hoek": "2.16.3" - } - }, - "sshpk": { - "version": "1.13.1", - "bundled": true, - "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true - } - } - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "1.0.3", - "bundled": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "stringstream": { - "version": "0.0.5", - "bundled": true - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true - }, - "tar": { - "version": "2.2.1", - "bundled": true, - "requires": { - "block-stream": "0.0.9", - "fstream": "1.0.11", - "inherits": "2.0.3" - } - }, - "tar-pack": { - "version": "3.4.1", - "bundled": true, - "requires": { - "debug": "2.6.9", - "fstream": "1.0.11", - "fstream-ignore": "1.0.5", - "once": "1.4.0", - "readable-stream": "2.3.5", - "rimraf": "2.6.2", - "tar": "2.2.1", - "uid-number": "0.0.6" - } - }, - "tough-cookie": { - "version": "2.3.3", - "bundled": true, - "requires": { - "punycode": "1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "bundled": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "bundled": true, - "optional": true - }, - "uid-number": { - "version": "0.0.6", - "bundled": true - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true - }, - "uuid": { - "version": "3.1.0", - "bundled": true - }, - "verror": { - "version": "1.10.0", - "bundled": true, - "requires": { - "assert-plus": "1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "1.3.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true - } - } - }, - "wide-align": { - "version": "1.1.2", - "bundled": true, - "requires": { - "string-width": "1.0.2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true - } - } - }, "macos-release": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/macos-release/-/macos-release-1.1.0.tgz", @@ -6570,7 +5947,8 @@ "nan": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" + "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", + "optional": true }, "nanomatch": { "version": "1.2.9", @@ -7992,16 +7370,15 @@ } }, "realm": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/realm/-/realm-2.0.7.tgz", - "integrity": "sha1-1SbWxzksVklafHgASDwG61hcbdY=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/realm/-/realm-2.3.3.tgz", + "integrity": "sha1-3Z3AE3+VsXAWVLqRk5KNUurEI50=", "requires": { "command-line-args": "4.0.7", "decompress": "4.2.0", - "decompress-tarxz": "2.1.1", "fs-extra": "4.0.3", "ini": "1.3.5", - "nan": "2.10.0", + "nan": "2.8.0", "node-fetch": "1.7.3", "node-pre-gyp": "0.6.39", "progress": "2.0.0", @@ -8030,6 +7407,11 @@ "graceful-fs": "4.1.11" } }, + "nan": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz", + "integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=" + }, "stream-counter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/stream-counter/-/stream-counter-1.0.0.tgz", diff --git a/package.json b/package.json index 252898e5b8..88b81665bc 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "react-native-testfairy": "2.8.0", "react-native-udp": "2.2.1", "react-native-webview-bridge": "github:status-im/react-native-webview-bridge#feature/camera-permissions", - "realm": "2.0.7", + "realm": "2.3.3", "rn-snoopy": "github:status-im/rn-snoopy", "string_decoder": "0.10.31", "url": "0.10.3", diff --git a/resources/default_contact_groups.json b/resources/default_contact_groups.json index 6585e43349..9b8a0c02af 100644 --- a/resources/default_contact_groups.json +++ b/resources/default_contact_groups.json @@ -13,7 +13,22 @@ "Dentacoin", "Augur", "Ethlance", - "Commiteth" + "Commiteth", + "cryptokitties", + "cryptopunks", + "name-bazaar", + "cent", + "erc-dex", + "oasis-direct", + "etherbots", + "peepeth", + "hexel", + "kyber", + "bancor", + "opensea", + "decentraland", + "cryptocribs", + "cryptofighters" ] }, "state-of-dapps": @@ -26,9 +41,7 @@ [ "flight-delays-suck", "FirstBlood", - "auction-house", - "gnosis", - "mkr-market" + "auction-house" ] } } diff --git a/resources/default_contacts.json b/resources/default_contacts.json index 8065063c1b..8bb27e2ef7 100644 --- a/resources/default_contacts.json +++ b/resources/default_contacts.json @@ -26,7 +26,7 @@ "en": "Jarrad" }, "photo-path": "contacts://jarrad", - "add-chat?": false, + "public-key": "0x0428c9d6c1aaaa8369a7c63819684f30e34396dc0907d49afeac85a0a774ccb919b3482097d992e66bcc538e7a0c6acf874c77748f396f53c0a102e10d1a37765b", "dapp?": false }, @@ -42,7 +42,6 @@ { "en": "http://auctionhouse.dappbench.com" }, - "groups": ["state-of-dapps"], "description": "Decentralized auctions for on-chain assets." }, @@ -58,7 +57,6 @@ { "en": "https://fdd.etherisc.com" }, - "groups": ["state-of-dapps"], "description": "Get instant payout in case your flight is late." }, @@ -74,7 +72,6 @@ { "en": "https://app.firstblood.io" }, - "groups": ["state-of-dapps"], "description": "ESports for Everyone! A platform that lets players challenge the field and win rewards." }, @@ -88,9 +85,8 @@ "dapp?": true, "dapp-url": { - "en": "https://district0x.github.io/ethlance/resources/public/" + "en": "https://district0x.github.io/ethlance/resources/public/" }, - "groups": ["dapps"], "description": "The future of work is now. Hire people or work yourself in return for ETH." }, @@ -106,121 +102,106 @@ { "en": "https://www.cryptokitties.co" }, - "groups": ["dapps"], "description": "Collect and breed adorable digital cats." }, - "cryptopunks": { - "name" : {"en" : "CryptoPunks"}, - "description": "10,000 unique collectible punks", - "dapp-url": {"en" :"https://www.larvalabs.com/cryptopunks"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://cryptopunks" - }, - "name-bazaar": { - "name" : {"en" : "Name Bazaar"}, - "description": "ENS name marketplace", - "dapp-url": {"en": "https://namebazaar.io"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://name-bazaar" - }, - "cent": { - "name" : {"en" : "Cent"}, - "description": "Get wisdom, get money", - "dapp-url": {"en" : "https://beta.cent.co"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://cent" - }, - "erc-dex": { - "name" : {"en" : "ERC dEX"}, - "description": "Trustless trading has arrived on Ethereum", - "dapp-url": {"en" : "https://app.ercdex.com/"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://erc-dex" - }, - "oasis-direct": { - "name" : {"en" : "Oasis Direct"}, - "description": "The first decentralized instant exchange", - "dapp-url": {"en" : "https://oasis.direct/"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://oasis-direct" - }, - "etherbots": { - "name" : {"en" : "Etherbots"}, - "description": "Robot wars on the Ethereum Platform", - "dapp-url": {"en" : "https://etherbots.io/"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://etherbots" - }, - "peepeth": { - "name" : {"en" : "Peepeth"}, - "description": "Blockchain-powered microblogging", - "dapp-url": {"en" : "http://peepeth.com/"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://peepeth" - }, - "hexel": { - "name" : {"en" : "Hexel"}, - "description": "Create your own cryptocurrency", - "dapp-url": {"en" : "https://www.onhexel.com/"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://hexel" - }, - "kyber": { - "name" : {"en" : "Kyber"}, - "description": "On-chain, instant and liquid platform for exchange and payment service", - "dapp-url": {"en" : "https://web3.kyber.network"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://kyber" - }, - "bancor": { - "name" : {"en" : "Bancor"}, - "description": "Bancor is a decentralized liquidity network", - "dapp-url": {"en" : "https://www.bancor.network/"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://bancor" - }, - "opensea": { - "name" : {"en" : "OpenSea"}, - "description": "The largest decentralized marketplace for cryptogoods", - "dapp-url": {"en" : "https://opensea.io"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://opensea" - }, - "decentraland": { - "name" : {"en" : "Decentraland"}, - "description": "Decentraland is a virtual reality platform powered by the Ethereum blockchain.", - "dapp-url": {"en" : "https://market.decentraland.org/"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://decentraland" - }, - "cryptocribs": { - "name" : {"en" : "CryptoCribs"}, - "description": "Travel the globe. Pay in crypto.", - "dapp-url": {"en" : "https://cryptocribs.com"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://cryptocribs" - }, - "cryptofighters": { - "name" : {"en" : "CryptoFighters"}, - "description": "Collect train and fight digital fighters.", - "dapp-url": {"en" : "https://cryptofighters.io"}, - "groups": ["dapps"], - "dapp?": true, - "photo-path": "contacts://cryptofighters" - } + "cryptopunks": { + "name" : {"en" : "CryptoPunks"}, + "description": "10,000 unique collectible punks", + "dapp-url": {"en" :"https://www.larvalabs.com/cryptopunks"}, + "dapp?": true, + "photo-path": "contacts://cryptopunks" + }, + "name-bazaar": { + "name" : {"en" : "Name Bazaar"}, + "description": "ENS name marketplace", + "dapp-url": {"en": "https://namebazaar.io"}, + "dapp?": true, + "photo-path": "contacts://name-bazaar" + }, + "cent": { + "name" : {"en" : "Cent"}, + "description": "Get wisdom, get money", + "dapp-url": {"en" : "https://beta.cent.co"}, + "dapp?": true, + "photo-path": "contacts://cent" + }, + "erc-dex": { + "name" : {"en" : "ERC dEX"}, + "description": "Trustless trading has arrived on Ethereum", + "dapp-url": {"en" : "https://app.ercdex.com/"}, + "dapp?": true, + "photo-path": "contacts://erc-dex" + }, + "oasis-direct": { + "name" : {"en" : "Oasis Direct"}, + "description": "The first decentralized instant exchange", + "dapp-url": {"en" : "https://oasis.direct/"}, + "dapp?": true, + "photo-path": "contacts://oasis-direct" + }, + "etherbots": { + "name" : {"en" : "Etherbots"}, + "description": "Robot wars on the Ethereum Platform", + "dapp-url": {"en" : "https://etherbots.io/"}, + "dapp?": true, + "photo-path": "contacts://etherbots" + }, + "peepeth": { + "name" : {"en" : "Peepeth"}, + "description": "Blockchain-powered microblogging", + "dapp-url": {"en" : "http://peepeth.com/"}, + "dapp?": true, + "photo-path": "contacts://peepeth" + }, + "hexel": { + "name" : {"en" : "Hexel"}, + "description": "Create your own cryptocurrency", + "dapp-url": {"en" : "https://www.onhexel.com/"}, + "dapp?": true, + "photo-path": "contacts://hexel" + }, + "kyber": { + "name" : {"en" : "Kyber"}, + "description": "On-chain, instant and liquid platform for exchange and payment service", + "dapp-url": {"en" : "https://web3.kyber.network"}, + "dapp?": true, + "photo-path": "contacts://kyber" + }, + "bancor": { + "name" : {"en" : "Bancor"}, + "description": "Bancor is a decentralized liquidity network", + "dapp-url": {"en" : "https://www.bancor.network/"}, + "dapp?": true, + "photo-path": "contacts://bancor" + }, + "opensea": { + "name" : {"en" : "OpenSea"}, + "description": "The largest decentralized marketplace for cryptogoods", + "dapp-url": {"en" : "https://opensea.io"}, + "dapp?": true, + "photo-path": "contacts://opensea" + }, + "decentraland": { + "name" : {"en" : "Decentraland"}, + "description": "Decentraland is a virtual reality platform powered by the Ethereum blockchain.", + "dapp-url": {"en" : "https://market.decentraland.org/"}, + "dapp?": true, + "photo-path": "contacts://decentraland" + }, + "cryptocribs": { + "name" : {"en" : "CryptoCribs"}, + "description": "Travel the globe. Pay in crypto.", + "dapp-url": {"en" : "https://cryptocribs.com"}, + "dapp?": true, + "photo-path": "contacts://cryptocribs" + }, + "cryptofighters": { + "name" : {"en" : "CryptoFighters"}, + "description": "Collect train and fight digital fighters.", + "dapp-url": {"en" : "https://cryptofighters.io"}, + "dapp?": true, + "photo-path": "contacts://cryptofighters" + } } diff --git a/src/status_im/chat/console.cljs b/src/status_im/chat/console.cljs index e0e62c964b..e01ce8682b 100644 --- a/src/status_im/chat/console.cljs +++ b/src/status_im/chat/console.cljs @@ -18,18 +18,16 @@ :content-type content-type}) (def chat - {:chat-id constants/console-chat-id - :name (i18n/label :t/status-console) - :color default-chat-color - :group-chat false - :is-active true - :unremovable? true - :timestamp (.getTime (js/Date.)) - :photo-path (str "contacts://" constants/console-chat-id) - :contacts [{:identity constants/console-chat-id - :text-color "#FFFFFF" - :background-color "#AB7967"}] - :last-clock-value 0}) + {:chat-id constants/console-chat-id + :name (i18n/label :t/status-console) + :color default-chat-color + :group-chat false + :is-active true + :unremovable? true + :timestamp (.getTime (js/Date.)) + :photo-path (str "contacts://" constants/console-chat-id) + :contacts [constants/console-chat-id] + :last-clock-value 0}) (def contact {:whisper-identity constants/console-chat-id diff --git a/src/status_im/chat/events.cljs b/src/status_im/chat/events.cljs index be03d88c64..4a1333d4e5 100644 --- a/src/status_im/chat/events.cljs +++ b/src/status_im/chat/events.cljs @@ -7,10 +7,14 @@ [status-im.chat.models :as models] [status-im.chat.console :as console] [status-im.chat.constants :as chat.constants] + [status-im.commands.events.loading :as events.loading] [status-im.ui.components.list-selection :as list-selection] [status-im.ui.screens.navigation :as navigation] + [status-im.ui.screens.group.events :as group.events] [status-im.utils.handlers :as handlers] - [status-im.transport.message.core :as transport] + [status-im.utils.contacts :as utils.contacts] + [status-im.transport.core :as transport] + [status-im.transport.message.core :as transport.message] [status-im.transport.message.v1.protocol :as protocol] [status-im.transport.message.v1.public-chat :as public-chat] [status-im.transport.message.v1.group-chat :as group-chat] @@ -81,36 +85,57 @@ :data-store/update-message (-> (get-in new-db msg-path) (select-keys [:message-id :user-statuses]))}))) (defn init-console-chat - [{:keys [chats] :as db}] - (if (chats constants/console-chat-id) - {:db db} - {:db (-> db - (assoc :current-chat-id constants/console-chat-id) - (update :chats assoc constants/console-chat-id console/chat)) - :dispatch [:add-contacts [console/contact]] - :data-store/save-chat console/chat - :data-store/save-contact console/contact})) + [{:keys [db] :as cofx}] + (when-not (get-in db [:chats constants/console-chat-id]) + {:db (-> db + (assoc :current-chat-id constants/console-chat-id) + (update :chats assoc constants/console-chat-id console/chat)) + :data-store/save-chat console/chat})) -(handlers/register-handler-fx - :init-console-chat - (fn [{:keys [db]} _] - (init-console-chat db))) +(defn- add-default-contacts + [{:keys [db default-contacts] :as cofx}] + (let [new-contacts (-> {} + (into (map (fn [[id props]] + (let [contact-id (name id)] + [contact-id {:whisper-identity contact-id + :address (utils.contacts/public-key->address contact-id) + :name (-> props :name :en) + :photo-path (:photo-path props) + :public-key (:public-key props) + :unremovable? (-> props :unremovable? boolean) + :hide-contact? (-> props :hide-contact? boolean) + :pending? (-> props :pending? boolean) + :dapp? (:dapp? props) + :dapp-url (-> props :dapp-url :en) + :bot-url (:bot-url props) + :description (:description props)}]))) + default-contacts) + (assoc constants/console-chat-id console/contact)) + existing-contacts (:contacts/contacts db) + contacts-to-add (select-keys new-contacts (set/difference (set (keys new-contacts)) + (set (keys existing-contacts))))] + (handlers/merge-fx cofx + {:db (update db :contacts/contacts merge contacts-to-add) + :data-store/save-contacts (vals contacts-to-add)} + (events.loading/load-commands)))) (handlers/register-handler-fx :initialize-chats - [(re-frame/inject-cofx :data-store/all-chats) + [(re-frame/inject-cofx :get-default-contacts-and-groups) + (re-frame/inject-cofx :data-store/all-chats) (re-frame/inject-cofx :data-store/inactive-chat-ids) (re-frame/inject-cofx :data-store/get-messages) (re-frame/inject-cofx :data-store/unviewed-messages) (re-frame/inject-cofx :data-store/message-ids) - (re-frame/inject-cofx :data-store/get-unanswered-requests)] + (re-frame/inject-cofx :data-store/get-unanswered-requests) + (re-frame/inject-cofx :data-store/get-local-storage-data)] (fn [{:keys [db all-stored-chats inactive-chat-ids stored-unanswered-requests get-stored-messages stored-unviewed-messages - stored-message-ids]} _] + stored-message-ids] :as cofx} _] (let [chat->message-id->request (reduce (fn [acc {:keys [chat-id message-id] :as request}] (assoc-in acc [chat-id message-id] request)) {} @@ -126,11 +151,13 @@ (-> chat-messages keys set)))))) {} all-stored-chats)] - (-> db - (assoc :chats chats - :deleted-chats inactive-chat-ids) - init-console-chat - (update :dispatch-n conj [:load-default-contacts!]))))) + (handlers/merge-fx cofx + {:db (assoc db + :chats chats + :deleted-chats inactive-chat-ids)} + (init-console-chat) + (group.events/add-default-groups) + (add-default-contacts))))) (handlers/register-handler-fx :browse-link-from-message @@ -147,7 +174,7 @@ (defn- send-messages-seen [chat-id message-ids {:keys [db] :as cofx}] (when (and (seq message-ids) (not (models/bot-only-chat? db chat-id))) - (transport/send (protocol/map->MessagesSeen {:message-ids message-ids}) chat-id cofx))) + (transport.message/send (protocol/map->MessagesSeen {:message-ids message-ids}) chat-id cofx))) ;;TODO (yenda) find a more elegant solution for system messages (defn- mark-messages-seen @@ -254,11 +281,20 @@ (fn [cofx [chat]] (models/update-chat chat cofx))) +(defn- remove-transport [chat-id {:keys [db] :as cofx}] + (let [{:keys [group-chat public?]} (get-in db [:chats chat-id])] + ;; if this is private group chat, we have to broadcast leave and unsubscribe after that + (if (and group-chat (not public?)) + (handlers/merge-fx cofx (transport.message/send (group-chat/GroupLeave.) chat-id)) + (handlers/merge-fx cofx (transport/unsubscribe-from-chat chat-id))))) + (handlers/register-handler-fx :remove-chat [re-frame/trim-v] (fn [cofx [chat-id]] - (models/remove-chat chat-id cofx))) + (handlers/merge-fx cofx + (models/remove-chat chat-id) + (remove-transport chat-id)))) (handlers/register-handler-fx :remove-chat-and-navigate-home @@ -266,6 +302,7 @@ (fn [cofx [chat-id]] (handlers/merge-fx cofx (models/remove-chat chat-id) + (remove-transport chat-id) (navigation/replace-view :home)))) (handlers/register-handler-fx @@ -312,28 +349,16 @@ (models/add-group-chat random-id chat-name (:current-public-key db) selected-contacts) (navigation/navigate-to-clean :home) (navigate-to-chat random-id {}) - (transport/send (group-chat/GroupAdminUpdate. chat-name selected-contacts) random-id))))) - -(defn- broadcast-leave [{:keys [public? chat-id]} cofx] - (when-not public? - (transport/send (group-chat/GroupLeave.) chat-id cofx))) - -(handlers/register-handler-fx - :leave-group-chat - ;; stop listening to group here - (fn [{{:keys [current-chat-id chats] :as db} :db :as cofx} _] - (handlers/merge-fx cofx - (models/remove-chat current-chat-id) - (navigation/replace-view :home) - (broadcast-leave (get chats current-chat-id))))) + (transport.message/send (group-chat/GroupAdminUpdate. chat-name selected-contacts) random-id))))) (handlers/register-handler-fx :leave-group-chat? - (fn [_ _] + [re-frame/trim-v] + (fn [_ [chat-id]] {:show-confirmation {:title (i18n/label :t/leave-confirmation) :content (i18n/label :t/leave-group-chat-confirmation) :confirm-button-text (i18n/label :t/leave) - :on-accept #(re-frame/dispatch [:leave-group-chat])}})) + :on-accept #(re-frame/dispatch [:remove-chat-and-navigate-home chat-id])}})) (handlers/register-handler-fx :show-profile diff --git a/src/status_im/chat/models.cljs b/src/status_im/chat/models.cljs index 5dd1b6b083..d3316a7df1 100644 --- a/src/status_im/chat/models.cljs +++ b/src/status_im/chat/models.cljs @@ -1,8 +1,7 @@ (ns status-im.chat.models (:require [status-im.ui.components.styles :as styles] [status-im.utils.gfycat.core :as gfycat] - [status-im.utils.handlers :as handlers] - [status-im.transport.core :as transport])) + [status-im.utils.handlers :as handlers])) (defn set-chat-ui-props "Updates ui-props in active chat by merging provided kvs into them" @@ -17,14 +16,14 @@ (defn- create-new-chat [chat-id {:keys [db now]}] (let [name (get-in db [:contacts/contacts chat-id :name])] - {:chat-id chat-id - :name (or name (gfycat/generate-gfy chat-id)) - :color styles/default-chat-color - :group-chat false - :is-active true - :timestamp now - :contacts [{:identity chat-id}] - :last-clock-value 0})) + {:chat-id chat-id + :name (or name (gfycat/generate-gfy chat-id)) + :color styles/default-chat-color + :group-chat false + :is-active true + :timestamp now + :contacts [chat-id] + :last-clock-value 0})) (defn add-chat "Adds new chat to db & realm, if the chat with same id already exists, justs restores it" @@ -36,38 +35,38 @@ (assoc (get-stored-chat chat-id) :is-active true) (create-new-chat chat-id cofx)) chat-props)] - {:db (-> db - (update :chats assoc chat-id new-chat) - (update :deleted-chats (fnil disj #{}) chat-id)) + {:db (-> db + (update :chats assoc chat-id new-chat) + (update :deleted-chats (fnil disj #{}) chat-id)) :data-store/save-chat new-chat}))) (defn add-public-chat "Adds new public group chat to db & realm" [topic {:keys [db now] :as cofx}] - (let [chat {:chat-id topic - :name topic - :color styles/default-chat-color - :group-chat true - :public? true - :is-active true - :timestamp now - :last-clock-value 0}] - {:db (assoc-in db [:chats topic] chat) + (let [chat {:chat-id topic + :name topic + :color styles/default-chat-color + :group-chat true + :public? true + :is-active true + :timestamp now + :last-clock-value 0}] + {:db (assoc-in db [:chats topic] chat) :data-store/save-chat chat})) (defn add-group-chat "Adds new private group chat to db & realm" [chat-id chat-name admin participants {:keys [db now] :as cofx}] - (let [chat {:chat-id chat-id - :name chat-name - :color styles/default-chat-color - :group-chat true - :group-admin admin - :is-active true - :timestamp now - :contacts (mapv (partial hash-map :identity) participants) - :last-clock-value 0}] - {:db (assoc-in db [:chats chat-id] chat) + (let [chat {:chat-id chat-id + :name chat-name + :color styles/default-chat-color + :group-chat true + :group-admin admin + :is-active true + :timestamp now + :contacts participants + :last-clock-value 0}] + {:db (assoc-in db [:chats chat-id] chat) :data-store/save-chat chat})) ;; TODO (yenda): there should be an option to update the timestamp @@ -82,7 +81,7 @@ (let [chat (merge (or (get chats chat-id) (create-new-chat chat-id cofx)) chat-props)] - {:db (update-in db [:chats chat-id] merge chat) + {:db (update-in db [:chats chat-id] merge chat) :data-store/save-chat chat})))) ;; TODO (yenda): an upsert is suppose to add the entry if it doesn't @@ -98,17 +97,16 @@ (> timestamp removed-from-at))) (defn remove-chat [chat-id {:keys [db] :as cofx}] - (let [{:keys [chat-id group-chat debug?]} (get-in db [:chats chat-id]) - fx (cond-> {:db (-> db - (update :chats dissoc chat-id) - (update :deleted-chats (fnil conj #{}) chat-id))} - (or group-chat debug?) - (assoc :data-store/delete-messages chat-id) - debug? - (assoc :data-store/delete-chat chat-id) - (not debug?) - (assoc :data-store/deactivate-chat chat-id))] - (handlers/merge-fx cofx fx (transport/unsubscribe-from-chat chat-id)))) + (let [{:keys [chat-id group-chat debug?]} (get-in db [:chats chat-id])] + (cond-> {:db (-> db + (update :chats dissoc chat-id) + (update :deleted-chats (fnil conj #{}) chat-id))} + (or group-chat debug?) + (assoc :data-store/delete-messages chat-id) + debug? + (assoc :data-store/delete-chat chat-id) + (not debug?) + (assoc :data-store/deactivate-chat chat-id)))) (defn bot-only-chat? [db chat-id] (let [{:keys [group-chat contacts]} (get-in db [:chats chat-id])] diff --git a/src/status_im/chat/models/commands.cljs b/src/status_im/chat/models/commands.cljs index fb521f041f..80398c9035 100644 --- a/src/status_im/chat/models/commands.cljs +++ b/src/status_im/chat/models/commands.cljs @@ -10,7 +10,7 @@ {} name->ref)) -(defn- is-dapp? [all-contacts {:keys [identity]}] +(defn- is-dapp? [all-contacts identity] (get-in all-contacts [identity :dapp?])) (defn command-name [{:keys [name]}] @@ -30,8 +30,7 @@ humans? (conj :humans) public? (conj :public-chats)) global-access-scope (conj basic-access-scope :global) - member-access-scopes (into #{} (map (comp (partial conj basic-access-scope) :identity)) - contacts)] + member-access-scopes (into #{} (map (partial conj basic-access-scope)) contacts)] (reduce (fn [acc access-scope] (merge acc (resolve-references all-contacts (get-in access-scope->commands-responses [access-scope type])))) diff --git a/src/status_im/chat/screen.cljs b/src/status_im/chat/screen.cljs index 1331c0afef..78d8e0ba68 100644 --- a/src/status_im/chat/screen.cljs +++ b/src/status_im/chat/screen.cljs @@ -61,7 +61,7 @@ :icon-opts {:color :black :accessibility-label :chat-menu-button} :handler #(on-options chat-id name group-chat public?)}]])] - (when-not (or public? group-chat) [add-contact-bar (-> contacts first :identity)])])) + (when-not (or public? group-chat) [add-contact-bar (first contacts)])])) (defmulti message-row (fn [{{:keys [type]} :row}] type)) @@ -82,10 +82,10 @@ timeout (if platform/android? 50 0)] {:component-did-mount (fn [_] (animation/start - (animation/anim-sequence - [(animation/anim-delay timeout) - (animation/spring opacity {:toValue 1 - :duration duration})])))} + (animation/anim-sequence + [(animation/anim-delay timeout) + (animation/spring opacity {:toValue 1 + :duration duration})])))} [react/with-activity-indicator {:style style/message-view-preview :preview [react/view style/message-view-preview]} diff --git a/src/status_im/commands/events/loading.cljs b/src/status_im/commands/events/loading.cljs index 603d26db91..240337df1f 100644 --- a/src/status_im/commands/events/loading.cljs +++ b/src/status_im/commands/events/loading.cljs @@ -46,23 +46,31 @@ {::evaluate-jail-n [{:jail-id whisper-identity :jail-resource commands-snippet}]})) +(defn load-commands-for-bot + "This function takes coeffects, effects, bot contact and adds effects + for loading all commands/responses/subscriptions." + [cofx fx {:keys [whisper-identity bot-url]}] + (if-let [commands-resource (js-resources/get-resource bot-url)] + (merge-with into fx (evaluate-commands-in-jail cofx commands-resource whisper-identity)) + (update fx :http-get-n conj {:url bot-url + :response-validator valid-network-resource? + :success-event-creator (fn [commands-resource] + [::evaluate-commands-in-jail commands-resource whisper-identity]) + :failure-event-creator (fn [error-response] + [::proceed-loading whisper-identity {:error error-response}])}))) + (defn load-commands - "This function takes coeffects, effects and contact and adds effects - for loading all commands/responses/subscriptions. + "This function takes coeffects and produces effects + for loading all commands/responses/subscriptions for existing bot contacts. It's currently working only for bots, eq we are not evaluating dapp resources in jail at all." - [cofx fx {:keys [whisper-identity bot-url]}] - (if bot-url - (if-let [commands-resource (js-resources/get-resource bot-url)] - (merge-with into fx (evaluate-commands-in-jail cofx commands-resource whisper-identity)) - (update fx :http-get-n conj {:url bot-url - :response-validator valid-network-resource? - :success-event-creator (fn [commands-resource] - [::evaluate-commands-in-jail commands-resource whisper-identity]) - :failure-event-creator (fn [error-response] - [::proceed-loading whisper-identity {:error error-response}])})) - fx)) + [{:keys [db] :as cofx}] + (transduce (comp (map second) + (filter :bot-url)) + (completing (partial load-commands-for-bot cofx)) + {} + (:contacts/contacts db))) (defn- add-exclusive-choices [initial-scope exclusive-choices] (reduce (fn [scopes-set exclusive-choices] diff --git a/src/status_im/commands/handlers/debug.cljs b/src/status_im/commands/handlers/debug.cljs index 20a803ce84..24dc33d846 100644 --- a/src/status_im/commands/handlers/debug.cljs +++ b/src/status_im/commands/handlers/debug.cljs @@ -179,4 +179,4 @@ ::load-commands [re-frame/trim-v (re-frame/inject-cofx :data-store/get-local-storage-data)] (fn [cofx [contact]] - (loading-events/load-commands cofx {} contact))) + (loading-events/load-commands-for-bot cofx {} contact))) diff --git a/src/status_im/data_store/realm/chats.cljs b/src/status_im/data_store/realm/chats.cljs index 62b5e54a0d..d9fff175a6 100644 --- a/src/status_im/data_store/realm/chats.cljs +++ b/src/status_im/data_store/realm/chats.cljs @@ -72,43 +72,25 @@ (fn [] (doto chat (aset "is-active" false) - (aset "removed-at" (datetime/timestamp))))))) - -(defn get-contacts - [chat-id] - (-> @realm/account-realm - (realm/get-one-by-field :chat :chat-id chat-id) - (object/get "contacts"))) - -(defn- save-contacts - [identities contacts added-at] - (doseq [contact-identity identities] - (if-let [contact (.find contacts (fn [object _ _] - (= contact-identity (object/get object "identity"))))] - (doto contact - (aset "is-in-chat" true) - (aset "added-at" added-at)) - (.push contacts (clj->js {:identity contact-identity - :added-at added-at}))))) + (aset "removed-at" (datetime/timestamp))))))) (defn add-contacts [chat-id identities] - (let [contacts (get-contacts chat-id) - added-at (datetime/timestamp)] + (let [chat (get-by-id-obj chat-id) + contacts (object/get chat "contacts")] (realm/write @realm/account-realm - #(save-contacts identities contacts added-at)))) - -(defn- delete-contacts - [identities contacts] - (doseq [contact-identity identities] - (when-let [contact (.find contacts (fn [object _ _] - (= contact-identity (object/get object "identity"))))] - (realm/delete @realm/account-realm contact)))) + #(aset chat "contacts" + (clj->js (into #{} (concat identities + (realm/js-object->clj contacts)))))))) (defn remove-contacts [chat-id identities] - (let [contacts (get-contacts chat-id)] - (delete-contacts identities contacts))) + (let [chat (get-by-id-obj chat-id) + contacts (object/get chat "contacts")] + (realm/write @realm/account-realm + #(aset chat "contacts" + (clj->js (remove (into #{} identities) + (realm/js-object->clj contacts))))))) (defn save-property [chat-id property-name value] diff --git a/src/status_im/data_store/realm/contact_groups.cljs b/src/status_im/data_store/realm/contact_groups.cljs index ac1e02af9e..ecb00001be 100644 --- a/src/status_im/data_store/realm/contact_groups.cljs +++ b/src/status_im/data_store/realm/contact_groups.cljs @@ -33,21 +33,15 @@ (when-let [group (realm/get-one-by-field @realm/account-realm :contact-group :group-id group-id)] (realm/delete @realm/account-realm group))) -(defn get-contacts +(defn- get-by-id-obj [group-id] - (-> @realm/account-realm - (realm/get-one-by-field :contact-group :group-id group-id) - (object/get "contacts"))) - -(defn- save-contacts - [identities contacts] - (doseq [contact-identity identities] - (when-not (.find contacts (fn [object _ _] - (= contact-identity (object/get object "identity")))) - (.push contacts (clj->js {:identity contact-identity}))))) + (realm/get-one-by-field @realm/account-realm :contact-group :group-id group-id)) (defn add-contacts [group-id identities] - (let [contacts (get-contacts group-id)] + (let [group (get-by-id-obj group-id) + contacts (object/get group "contacts")] (realm/write @realm/account-realm - #(save-contacts identities contacts)))) + #(aset group "contacts" + (clj->js (into #{} (concat identities + (realm/js-object->clj contacts)))))))) diff --git a/src/status_im/data_store/realm/schemas/account/v1/chat.cljs b/src/status_im/data_store/realm/schemas/account/v1/chat.cljs index 4000ce5186..4f93cb915b 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/chat.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/chat.cljs @@ -13,10 +13,7 @@ :optional true} :is-active :bool :timestamp :int - :contacts {:type :list - :objectType :chat-contact} - :unremovable? {:type :bool - :default false} + :contacts {:type "string[]"} :removed-at {:type :int :optional true} :removed-from-at {:type :int diff --git a/src/status_im/data_store/realm/schemas/account/v1/contact_group.cljs b/src/status_im/data_store/realm/schemas/account/v1/contact_group.cljs index 24d64708bf..813d56810f 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/contact_group.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/contact_group.cljs @@ -6,7 +6,8 @@ :properties {:group-id :string :name :string :timestamp :int - :order :int - :pending? {:type :bool :default false} - :contacts {:type :list - :objectType :group-contact}}}) + :order :int + :contacts {:type "string[]"}}}) + +(defn migration [old-realm new-realm] + (log/debug "migrating group schema v1")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/core.cljs b/src/status_im/data_store/realm/schemas/account/v1/core.cljs index 5395941879..270d81bf5b 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/core.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/core.cljs @@ -1,13 +1,11 @@ (ns status-im.data-store.realm.schemas.account.v1.core (:require [status-im.data-store.realm.schemas.account.v1.chat :as chat] [status-im.data-store.realm.schemas.account.v1.transport :as transport] - [status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact] [status-im.data-store.realm.schemas.account.v1.contact :as contact] [status-im.data-store.realm.schemas.account.v1.message :as message] [status-im.data-store.realm.schemas.account.v1.request :as request] [status-im.data-store.realm.schemas.account.v1.user-status :as user-status] [status-im.data-store.realm.schemas.account.v1.contact-group :as contact-group] - [status-im.data-store.realm.schemas.account.v1.group-contact :as group-contact] [status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage] [status-im.data-store.realm.schemas.account.v1.browser :as browser] [goog.object :as object] @@ -16,14 +14,12 @@ [clojure.string :as string])) (def schema [chat/schema - chat-contact/schema transport/schema contact/schema message/schema request/schema user-status/schema contact-group/schema - group-contact/schema local-storage/schema browser/schema]) diff --git a/src/status_im/transport/handlers.cljs b/src/status_im/transport/handlers.cljs index de13057ccf..e7336bccd7 100644 --- a/src/status_im/transport/handlers.cljs +++ b/src/status_im/transport/handlers.cljs @@ -15,7 +15,7 @@ (handlers/register-handler-fx :protocol/receive-whisper-message - [re-frame/trim-v] + [re-frame/trim-v (re-frame/inject-cofx :random-id)] (fn [cofx [js-error js-message chat-id]] (let [{:keys [payload sig]} (js->clj js-message :keywordize-keys true) status-message (-> payload diff --git a/src/status_im/transport/message/v1/group_chat.cljs b/src/status_im/transport/message/v1/group_chat.cljs index 45eb792e0c..21f7932939 100644 --- a/src/status_im/transport/message/v1/group_chat.cljs +++ b/src/status_im/transport/message/v1/group_chat.cljs @@ -21,7 +21,7 @@ (defrecord NewGroupKey [chat-id sym-key message] message/StatusMessage (send [this _ cofx] - (let [public-keys (map :identity (get-in cofx [:db :chats chat-id :contacts]))] + (let [public-keys (get-in cofx [:db :chats chat-id :contacts])] (protocol/multi-send-with-pubkey {:public-keys public-keys :chat-id chat-id :payload this} @@ -32,6 +32,7 @@ :sym-key sym-key :on-success (fn [sym-key sym-key-id] (re-frame/dispatch [::add-new-sym-key {:chat-id chat-id + :signature signature :sym-key sym-key :sym-key-id sym-key-id :message message}]))}} @@ -80,20 +81,20 @@ (handlers/merge-fx cofx (init-chat-if-new chat-id) (send-new-group-key this chat-id))) - (receive [this chat-id signature {:keys [now db] :as cofx}] + (receive [this chat-id signature {:keys [now db random-id] :as cofx}] (let [me (:current-public-key db)] ;; we have to check if we already have a chat, or it's a new one (if-let [{:keys [group-admin contacts] :as chat} (get-in db [:chats chat-id])] ;; update for existing group chat - (when (= signature group-admin) ;; make sure that admin is the one making changes + (when (and (= signature group-admin) ;; make sure that admin is the one making changes + (not= (set contacts) (set participants))) ;; make sure it's actually changing something (let [{:keys [removed added]} (participants-diff (set contacts) (set participants)) admin-name (or (get-in cofx [db :contacts/contacts group-admin :name]) - group-admin) - message-id (transport.utils/message-id this)] + group-admin)] (if (removed me) ;; we were removed (handlers/merge-fx cofx (models.message/receive - (models.message/system-message chat-id message-id now + (models.message/system-message chat-id random-id now (str admin-name " " (i18n/label :t/removed-from-chat)))) (models.chat/update-chat {:chat-id chat-id :removed-from-at now @@ -101,7 +102,7 @@ (transport/unsubscribe-from-chat chat-id)) (handlers/merge-fx cofx (models.message/receive - (models.message/system-message chat-id message-id now + (models.message/system-message chat-id random-id now (prepare-system-message admin-name added removed @@ -119,15 +120,14 @@ :payload this :success-event [::unsubscribe-from-chat chat-id]} cofx)) - (receive [this chat-id signature {:keys [db now] :as cofx}] - (let [message-id (transport.utils/message-id this) - me (:current-public-key db) + (receive [this chat-id signature {:keys [db now random-id] :as cofx}] + (let [me (:current-public-key db) participant-leaving-name (or (get-in db [:contacts/contacts signature :name]) signature)] - (when-not (= me signature) + (when (get-in db [:chats chat-id]) ;; chat is present (handlers/merge-fx cofx (models.message/receive - (models.message/system-message chat-id message-id now + (models.message/system-message chat-id random-id now (str participant-leaving-name " " (i18n/label :t/left)))) (group/participants-removed chat-id #{signature}) (send-new-group-key nil chat-id)))))) @@ -160,8 +160,8 @@ (handlers/register-handler-fx ::add-new-sym-key - [re-frame/trim-v] - (fn [{:keys [db] :as cofx} [{:keys [sym-key-id sym-key chat-id message]}]] + [re-frame/trim-v (re-frame/inject-cofx :random-id)] + (fn [{:keys [db] :as cofx} [{:keys [sym-key-id sym-key chat-id signature message]}]] (let [{:keys [web3 current-public-key]} db fx {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) :shh/add-filter {:web3 web3 @@ -175,5 +175,5 @@ (assoc :sym-key sym-key))}}] ;; if new sym-key is wrapping some message, call receive on it as well, if not just update the transport layer (if message - (handlers/merge-fx cofx fx (message/receive message chat-id chat-id)) + (handlers/merge-fx cofx fx (message/receive message chat-id signature)) fx)))) diff --git a/src/status_im/transport/message/v1/protocol.cljs b/src/status_im/transport/message/v1/protocol.cljs index 1413b82d85..e42b79d492 100644 --- a/src/status_im/transport/message/v1/protocol.cljs +++ b/src/status_im/transport/message/v1/protocol.cljs @@ -63,11 +63,17 @@ (defn- prepare-recipients [public-keys db] (map (fn [public-key] - (select-keys (get-in db [:transport/chats public-key]) [:topic :sym-key-id])) + (if-let [{:keys [topic sym-key-id]} (get-in db [:transport/chats public-key])] + {:topic topic + :sym-key-id sym-key-id} + {:topic (transport.utils/get-topic constants/contact-discovery) + :pub-key public-key})) public-keys)) (defn multi-send-with-pubkey - "Sends payload to multiple participants selected by `:public-keys` key." + "Sends payload to multiple participants selected by `:public-keys` key. + If there is already established symmetric key with the participant, uses that (for efficiency), + if not, uses asymetric encryption." [{:keys [payload public-keys success-event]} {:keys [db] :as cofx}] (let [{:keys [current-public-key web3]} db recipients (prepare-recipients public-keys db)] diff --git a/src/status_im/transport/shh.cljs b/src/status_im/transport/shh.cljs index 6defd5aa41..608821946c 100644 --- a/src/status_im/transport/shh.cljs +++ b/src/status_im/transport/shh.cljs @@ -82,11 +82,11 @@ :or {error-event :protocol/send-status-message-error}}] (let [whisper-message (update message :payload (comp transport.utils/from-utf8 transit/serialize))] - (doseq [{:keys [sym-key-id topic]} recipients] + (doseq [{:keys [sym-key-id pub-key topic]} recipients] (post-message {:web3 web3 - :whisper-message (assoc whisper-message - :symKeyID sym-key-id - :topic topic) + :whisper-message (cond-> (assoc whisper-message :topic topic) + sym-key-id (assoc :symKeyID sym-key-id) + pub-key (assoc :pubKey pub-key)) :on-success (if success-event #(re-frame/dispatch success-event) #(log/debug :shh/post-success)) diff --git a/src/status_im/ui/screens/add_new/views.cljs b/src/status_im/ui/screens/add_new/views.cljs index cf2f337e54..69434c937d 100644 --- a/src/status_im/ui/screens/add_new/views.cljs +++ b/src/status_im/ui/screens/add_new/views.cljs @@ -22,12 +22,12 @@ :on-press #(re-frame/dispatch [:navigate-to :new-chat])}] [action-button/action-separator] ;; TODO temporary removal before everything is fixed in group chats - #_[action-button/action-button - {:label (i18n/label :t/start-group-chat) - :accessibility-label :start-group-chat-button - :icon :icons/contacts - :icon-opts {:color colors/blue} - :on-press #(re-frame/dispatch [:open-contact-toggle-list :chat-group])}] + [action-button/action-button + {:label (i18n/label :t/start-group-chat) + :accessibility-label :start-group-chat-button + :icon :icons/contacts + :icon-opts {:color colors/blue} + :on-press #(re-frame/dispatch [:open-contact-toggle-list :chat-group])}] [action-button/action-separator] [action-button/action-button {:label (i18n/label :t/new-public-group-chat) diff --git a/src/status_im/ui/screens/contacts/events.cljs b/src/status_im/ui/screens/contacts/events.cljs index 8ac65dac68..b23f36a529 100644 --- a/src/status_im/ui/screens/contacts/events.cljs +++ b/src/status_im/ui/screens/contacts/events.cljs @@ -1,36 +1,22 @@ (ns status-im.ui.screens.contacts.events - (:require [cljs.reader :as reader] + (:require [clojure.set :as set] + [cljs.reader :as reader] [re-frame.core :as re-frame] [status-im.utils.handlers :as handlers] - [status-im.utils.contacts :as utils.contacts] - [status-im.utils.random :as random] - [status-im.utils.js-resources :as js-res] - [status-im.i18n :refer [label]] - [taoensso.timbre :as log] - [status-im.utils.js-resources :as js-res] - [status-im.utils.datetime :as datetime] + [status-im.utils.contacts :as utils.contacts] + [status-im.constants :as constants] [status-im.utils.identicon :as identicon] [status-im.utils.gfycat.core :as gfycat.core] [status-im.ui.screens.contacts.navigation] [status-im.ui.screens.navigation :as navigation] + [status-im.ui.screens.group.events :as group.events] [status-im.chat.console :as console-chat] [status-im.chat.events :as chat.events] - [status-im.chat.models :as chat.models] - [status-im.commands.events.loading :as loading-events] - [status-im.js-dependencies :as js-dependencies] + [status-im.chat.models :as chat.models] [status-im.transport.message.core :as transport] [status-im.transport.message.v1.contact :as message.v1.contact] [status-im.ui.screens.add-new.new-chat.db :as new-chat.db])) -;;;; COFX - -(re-frame/reg-cofx - ::get-default-contacts-and-groups - (fn [coeffects _] - (assoc coeffects - :default-contacts js-res/default-contacts - :default-groups js-res/default-contact-groups))) - ;;;; Handlers (defn- update-contact [{:keys [whisper-identity] :as contact} {:keys [db]}] @@ -38,84 +24,6 @@ {:db (update-in db [:contacts/contacts whisper-identity] merge contact) :data-store/save-contact contact})) -(defn- update-pending-status [old-contacts {:keys [whisper-identity pending?] :as contact}] - (let [{old-pending :pending? - :as old-contact} (get old-contacts whisper-identity) - pending?' (if old-contact (and old-pending pending?) pending?)] - (assoc contact :pending? (boolean pending?')))) - -(defn- public-key->address [public-key] - (let [length (count public-key) - normalized-key (case length - 132 (subs public-key 4) - 130 (subs public-key 2) - 128 public-key - nil)] - (when normalized-key - (subs (.sha3 js-dependencies/Web3.prototype normalized-key #js {:encoding "hex"}) 26)))) - -(defn- prepare-default-groups-events [groups default-groups] - [[:add-contact-groups - (for [[id {:keys [name contacts]}] default-groups - :let [id' (clojure.core/name id)] - :when (not (get groups id'))] - {:group-id id' - :name (:en name) - :order 0 - :timestamp (datetime/timestamp) - :contacts (mapv #(hash-map :identity %) contacts)})]]) - -;; NOTE(oskarth): We now overwrite default contacts upon upgrade with default_contacts.json data. -(defn- prepare-default-contacts-events [contacts default-contacts] - (let [default-contacts - (for [[id {:keys [name photo-path public-key add-chat? pending? description - dapp? dapp-url dapp-hash bot-url unremovable? hide-contact?]}] default-contacts - :let [id' (clojure.core/name id)]] - {:whisper-identity id' - :address (public-key->address id') - :name (:en name) - :photo-path photo-path - :public-key public-key - :unremovable? (boolean unremovable?) - :hide-contact? (boolean hide-contact?) - :pending? pending? - :dapp? dapp? - :dapp-url (:en dapp-url) - :bot-url bot-url - :description description - :dapp-hash dapp-hash}) - all-default-contacts (conj default-contacts console-chat/contact)] - [[:add-contacts all-default-contacts]])) - -(defn- prepare-add-chat-events [contacts default-contacts] - (for [[id {:keys [name add-chat?]}] default-contacts - :let [id' (clojure.core/name id)] - :when (and (not (get contacts id')) add-chat?)] - [:add-chat id' {:name (:en name)}])) - -(defn- prepare-add-contacts-to-groups-events [contacts default-contacts] - (let [groups (for [[id {:keys [groups]}] default-contacts - :let [id' (clojure.core/name id)] - :when (and (not (get contacts id')) groups)] - (for [group groups] - {:group-id group :whisper-identity id'})) - groups' (vals (group-by :group-id (flatten groups)))] - (for [contacts groups'] - [:add-contacts-to-group - (:group-id (first contacts)) - (mapv :whisper-identity contacts)]))) - -(handlers/register-handler-fx - :load-default-contacts! - [(re-frame/inject-cofx ::get-default-contacts-and-groups)] - (fn [{:keys [db default-contacts default-groups]} _] - (let [{:contacts/keys [contacts] :group/keys [contact-groups]} db] - {:dispatch-n (concat - (prepare-default-groups-events contact-groups default-groups) - (prepare-default-contacts-events contacts default-contacts) - (prepare-add-chat-events contacts default-contacts) - (prepare-add-contacts-to-groups-events contacts default-contacts))}))) - (handlers/register-handler-fx :load-contacts [(re-frame/inject-cofx :data-store/get-all-contacts)] @@ -124,24 +32,6 @@ contacts (into {} contacts-list)] {:db (update db :contacts/contacts #(merge contacts %))}))) -(handlers/register-handler-fx - :add-contacts - [(re-frame/inject-cofx :data-store/get-local-storage-data)] - (fn [{:keys [db] :as cofx} [_ new-contacts]] - (let [{:contacts/keys [contacts]} db - new-contacts' (->> new-contacts - (map #(update-pending-status contacts %)) - ;; NOTE(oskarth): Overwriting default contacts here - ;;(remove #(identities (:whisper-identity %))) - (map #(vector (:whisper-identity %) %)) - (into {})) - fx {:db (update db :contacts/contacts merge new-contacts') - :data-store/save-contacts (vals new-contacts')}] - (transduce (map second) - (completing (partial loading-events/load-commands (assoc cofx :db (:db fx)))) - fx - new-contacts')))) - (defn- add-new-contact [{:keys [whisper-identity] :as contact} {:keys [db]}] (let [new-contact (assoc contact :pending? false)] {:db (-> db @@ -168,7 +58,7 @@ (reader/read-string contact-info) (or (get contacts whisper-id) (utils.contacts/whisper-id->new-contact whisper-id))) - (assoc :address (public-key->address whisper-id)))) + (assoc :address (utils.contacts/public-key->address whisper-id)))) (defn add-contact [whisper-id {:keys [db] :as cofx}] (let [contact (build-contact whisper-id cofx)] diff --git a/src/status_im/ui/screens/contacts/subs.cljs b/src/status_im/ui/screens/contacts/subs.cljs index 02f9d315b2..6ca32a9052 100644 --- a/src/status_im/ui/screens/contacts/subs.cljs +++ b/src/status_im/ui/screens/contacts/subs.cljs @@ -44,7 +44,7 @@ (remove #(true? (:dapp? %)) contacts))) (defn filter-group-contacts [group-contacts contacts] - (let [group-contacts' (into #{} (map #(:identity %) group-contacts))] + (let [group-contacts' (into #{} group-contacts)] (filter #(group-contacts' (:whisper-identity %)) contacts))) (reg-sub :group-contacts @@ -59,7 +59,7 @@ (filter-group-contacts group-contacts contacts))) (defn filter-not-group-contacts [group-contacts contacts] - (let [group-contacts' (into #{} (map #(:identity %) group-contacts))] + (let [group-contacts' (into #{} group-contacts)] (remove #(group-contacts' (:whisper-identity %)) contacts))) (reg-sub :all-not-added-group-contacts @@ -123,10 +123,7 @@ (defn chat-contacts [[chat contacts] [_ fn]] (when chat - (let [current-participants (->> chat - :contacts - (map :identity) - set)] + (let [current-participants (-> chat :contacts set)] (fn #(current-participants (:whisper-identity %)) (vals contacts))))) diff --git a/src/status_im/ui/screens/events.cljs b/src/status_im/ui/screens/events.cljs index 3a28ff9699..4c3ded7bfe 100644 --- a/src/status_im/ui/screens/events.cljs +++ b/src/status_im/ui/screens/events.cljs @@ -275,10 +275,10 @@ {:dispatch-n (cond-> [[:initialize-account-db address] [:initialize-protocol address] [:initialize-sync-listener] - [:initialize-chats] - [:initialize-browsers] [:load-contacts] [:load-contact-groups] + [:initialize-chats] + [:initialize-browsers] [:initialize-debugging {:address address}] [:send-account-update-if-needed] [:update-wallet] diff --git a/src/status_im/ui/screens/group/chat_settings/events.cljs b/src/status_im/ui/screens/group/chat_settings/events.cljs index 20458f27dc..210fb50a02 100644 --- a/src/status_im/ui/screens/group/chat_settings/events.cljs +++ b/src/status_im/ui/screens/group/chat_settings/events.cljs @@ -20,9 +20,7 @@ :add-new-group-chat-participants [(re-frame/inject-cofx :random-id)] (fn [{{:keys [current-chat-id selected-participants] :as db} :db now :now message-id :random-id :as cofx} _] - (let [new-identities (map #(hash-map :identity %) selected-participants) - participants (concat (get-in db [:chats current-chat-id :contacts]) - selected-participants) + (let [participants (concat (get-in db [:chats current-chat-id :contacts]) selected-participants) contacts (:contacts/contacts db) added-participants-names (map #(get-in contacts [% :name]) selected-participants)] (handlers/merge-fx cofx @@ -39,8 +37,7 @@ :remove-group-chat-participants [re-frame/trim-v (re-frame/inject-cofx :random-id)] (fn [{{:keys [current-chat-id] :as db} :db now :now message-id :random-id :as cofx} [removed-participants]] - (let [participants (remove #(removed-participants (:identity %)) - (get-in db [:chats current-chat-id :contacts])) + (let [participants (remove removed-participants (get-in db [:chats current-chat-id :contacts])) contacts (:contacts/contacts db) removed-participants-names (map #(get-in contacts [% :name]) removed-participants)] (handlers/merge-fx cofx diff --git a/src/status_im/ui/screens/group/core.cljs b/src/status_im/ui/screens/group/core.cljs index 9bcfc4dae5..427c3df042 100644 --- a/src/status_im/ui/screens/group/core.cljs +++ b/src/status_im/ui/screens/group/core.cljs @@ -2,7 +2,7 @@ (defn participants-added [chat-id added-participants-set {:keys [db] :as cofx}] (when (seq added-participants-set) - {:db (update-in db [:chats chat-id :contacts] concat (mapv #(hash-map :identity %) added-participants-set)) + {:db (update-in db [:chats chat-id :contacts] concat added-participants-set) :data-store/add-chat-contacts [chat-id added-participants-set]})) (defn participants-removed [chat-id removed-participants-set {:keys [now db] :as cofx}] @@ -10,6 +10,5 @@ (let [{:keys [is-active timestamp]} (get-in db [:chats chat-id])] ;;TODO: not sure what this condition is for (when (and is-active (>= now timestamp)) - {:db (update-in db [:chats chat-id :contacts] - (partial remove (comp removed-participants-set :identity))) + {:db (update-in db [:chats chat-id :contacts] (partial remove removed-participants-set)) :data-store/remove-chat-contacts [chat-id removed-participants-set]})))) diff --git a/src/status_im/ui/screens/group/db.cljs b/src/status_im/ui/screens/group/db.cljs index 876bc8e826..84258bee69 100644 --- a/src/status_im/ui/screens/group/db.cljs +++ b/src/status_im/ui/screens/group/db.cljs @@ -13,11 +13,9 @@ (spec/def :group/name :global/not-empty-string) (spec/def :group/timestamp int?) (spec/def :group/pending? boolean?) -(spec/def :group/order int?) +(spec/def :group/order int?) -(spec/def :group-contact/identity :global/not-empty-string) - -(spec/def :group/contact (allowed-keys :req-un [:group-contact/identity])) +(spec/def :group/contact :global/not-empty-string) (spec/def :group/contacts (spec/nilable (spec/* :group/contact))) @@ -32,4 +30,4 @@ (spec/def :group/group-type (spec/nilable #{:chat-group :contact-group})) (spec/def :group/selected-contacts (spec/nilable (spec/* string?))) ;;list of group ids -(spec/def :group/groups-order (spec/nilable (spec/* string?))) \ No newline at end of file +(spec/def :group/groups-order (spec/nilable (spec/* string?))) diff --git a/src/status_im/ui/screens/group/events.cljs b/src/status_im/ui/screens/group/events.cljs index 01cb3ab5d5..96470dd878 100644 --- a/src/status_im/ui/screens/group/events.cljs +++ b/src/status_im/ui/screens/group/events.cljs @@ -1,109 +1,77 @@ (ns status-im.ui.screens.group.events - (:require [re-frame.core :refer [dispatch reg-fx reg-cofx inject-cofx]] - [status-im.utils.handlers :refer [register-handler-db register-handler-fx]] - [status-im.ui.components.styles :refer [default-chat-color]] - [clojure.string :as string] - [status-im.utils.random :as random] - [status-im.ui.screens.group.navigation] - [status-im.utils.datetime :as datetime] - [re-frame.core :as re-frame])) + (:require [clojure.set :as set] + [re-frame.core :as re-frame] + [status-im.utils.js-resources :as js-res] + [status-im.utils.handlers :as handlers] + [status-im.ui.screens.group.navigation])) + +;;;; COFX + +(re-frame/reg-cofx + :get-default-contacts-and-groups + (fn [coeffects _] + (assoc coeffects + :default-contacts js-res/default-contacts + :default-groups js-res/default-contact-groups))) ;;;; Handlers -(register-handler-db +(handlers/register-handler-db :deselect-contact (fn [db [_ id]] (update db :group/selected-contacts disj id))) -(register-handler-db +(handlers/register-handler-db :select-contact (fn [db [_ id]] (update db :group/selected-contacts conj id))) -(register-handler-db +(handlers/register-handler-db :deselect-participant (fn [db [_ id]] (update db :selected-participants disj id))) -(register-handler-db +(handlers/register-handler-db :select-participant (fn [db [_ id]] (update db :selected-participants conj id))) -(register-handler-fx +(handlers/register-handler-fx :create-new-contact-group - [(re-frame/inject-cofx :now)] - (fn [{{:group/keys [contact-groups selected-contacts] :as db} :db - now :now} [_ group-name]] - (let [selected-contacts' (mapv #(hash-map :identity %) selected-contacts) - new-group {:group-id (random/id) + [re-frame/trim-v (re-frame/inject-cofx :now) (re-frame/inject-cofx :random-id)] + (fn [{{:group/keys [contact-groups selected-contacts] :as db} :db group-id :random-id now :now} [group-name]] + (let [new-group {:group-id group-id :name group-name :order (count contact-groups) :timestamp now - :contacts selected-contacts'}] - {:db (update db :group/contact-groups merge {(:group-id new-group) new-group}) + :contacts selected-contacts}] + {:db (assoc-in db [:group/contact-groups group-id] new-group) :data-store/save-contact-group new-group}))) -(register-handler-fx - ::update-contact-group - (fn [{:keys [db]} [_ new-group]] - {:db (update db :group/contact-groups merge {(:group-id new-group) new-group}) - :data-store/save-contact-group new-group})) +(defn add-default-groups + [{:keys [db now default-groups]}] + (let [new-groups (into {} + (map (fn [[id props]] + (let [group-id (name id)] + [group-id {:group-id group-id + :name (-> props :name :en) + :order 0 + :timestamp now + :contacts (:contacts props)}]))) + default-groups) + existing-groups (:group/contact-groups db) + groups-to-add (select-keys new-groups (set/difference (set (keys new-groups)) + (set (keys existing-groups))))] + {:db (update db :group/contact-groups merge groups-to-add) + :data-store/save-contact-groups (vals groups-to-add)})) -(defn update-pending-status [old-groups {:keys [group-id pending?] :as group}] - (let [{old-pending :pending? - :as old-group} (get old-groups group-id) - pending?' (if old-pending (and old-pending pending?) pending?)] - (assoc group :pending? (boolean pending?')))) - -(register-handler-fx - :add-contact-groups - (fn [{{:group/keys [contact-groups] :as db} :db} [_ new-groups]] - (let [identities (set (keys contact-groups)) - old-groups-count (count identities) - new-groups' (->> new-groups - (map #(update-pending-status contact-groups %)) - (remove #(identities (:group-id %))) - (map #(vector (:group-id %2) (assoc %2 :order %1)) (iterate inc old-groups-count)) - (into {}))] - {:db (update db :group/contact-groups merge new-groups') - :data-store/save-contact-groups (into [] (vals new-groups'))}))) - -(register-handler-fx +(handlers/register-handler-fx :load-contact-groups - [(inject-cofx :data-store/get-all-contact-groups)] + [(re-frame/inject-cofx :data-store/get-all-contact-groups)] (fn [{:keys [db all-contact-groups]} _] {:db (assoc db :group/contact-groups all-contact-groups)})) -(defn move-item [v from to] - (if (< from to) - (concat (subvec v 0 from) - (subvec v (inc from) (inc to)) - [(v from)] - (subvec v (inc to))) - (concat (subvec v 0 to) - [(v from)] - (subvec v to from) - (subvec v (inc from))))) - -(register-handler-db - :change-contact-group-order - (fn [{:group/keys [groups-order] :as db} [_ from to]] - (if (>= to 0) - (assoc db :group/groups-order (move-item (vec groups-order) from to)) - db))) - -(register-handler-fx - :save-contact-group-order - (fn [{{:group/keys [contact-groups groups-order] :as db} :db} _] - (let [new-groups (mapv #(assoc (contact-groups (second %)) :order (first %)) - (map-indexed vector (reverse groups-order)))] - {:db (update db - :group/contact-groups - merge (map #(vector (:group-id %) %) new-groups)) - :data-store/save-contact-groups new-groups}))) - -(register-handler-fx +(handlers/register-handler-fx :set-contact-group-name (fn [{{:keys [new-chat-name] :group/keys [contact-group-id] :as db} :db} _] {:db (assoc-in db @@ -111,37 +79,20 @@ new-chat-name) :data-store/save-contact-group-property [contact-group-id :name new-chat-name]})) -(register-handler-fx +(handlers/register-handler-fx :add-selected-contacts-to-group (fn [{{:group/keys [contact-groups contact-group-id selected-contacts] :as db} :db} _] - (let [new-identities (mapv #(hash-map :identity %) selected-contacts)] - {:db (update-in db - [:group/contact-groups contact-group-id :contacts] - #(into [] (set (concat % new-identities)))) - :data-store/add-contacts-to-contact-group [contact-group-id selected-contacts]}))) + {:db (update-in db + [:group/contact-groups contact-group-id :contacts] + #(into [] (set (concat % selected-contacts)))) + :data-store/add-contacts-to-contact-group [contact-group-id selected-contacts]})) -(register-handler-fx - :add-contacts-to-group - (fn [{:keys [db]} [_ group-id contacts]] - (let [new-identities (mapv #(hash-map :identity %) contacts)] - (when (get-in db [:group/contact-groups group-id]) - {:db (update-in db [:group/contact-groups group-id :contacts] - #(into [] (set (concat % new-identities)))) - :data-store/add-contacts-to-contact-group [group-id contacts]})))) - -(defn remove-contact-from-group [whisper-identity] - (fn [contacts] - (remove #(= whisper-identity (:identity %)) contacts))) - -(register-handler-fx +(handlers/register-handler-fx :remove-contact-from-group - (fn [{:keys [db]} [_ whisper-identity group-id]] - (let [{:group/keys [contact-groups]} db - group' (update (contact-groups group-id) :contacts (remove-contact-from-group whisper-identity))] - {:dispatch [::update-contact-group group']}))) - -(register-handler-fx - :delete-contact-group - (fn [{{:group/keys [contact-group-id] :as db} :db} _] - {:db (assoc-in db [:group/contact-groups contact-group-id :pending?] true) - :data-store/save-contact-group-property [contact-group-id :pending? true]})) + [re-frame/trim-v] + (fn [{:keys [db]} [whisper-identity group-id]] + (let [group (-> db + (get-in [:group/contact-groups group-id]) + (update :contacts (partial remove #(= whisper-identity %))))] + {:db (assoc-in db [:group/contact-groups group-id] group) + :data-store/save-contact-group group}))) diff --git a/src/status_im/ui/screens/profile/group_chat/views.cljs b/src/status_im/ui/screens/profile/group_chat/views.cljs index b930b69f23..da3818fabc 100644 --- a/src/status_im/ui/screens/profile/group_chat/views.cljs +++ b/src/status_im/ui/screens/profile/group_chat/views.cljs @@ -38,12 +38,10 @@ (defn actions [admin? chat-id] (concat - ;; NOTE(goranjovic) - group chat participant removal has been temporarily disabled - ;; due to this bug - https://github.com/status-im/status-react/issues/3463 - #_(when admin? - [{:label (i18n/label :add-members) - :icon :icons/add - :action #(re-frame/dispatch [:navigate-to :add-participants-toggle-list])}]) + (when admin? + [{:label (i18n/label :add-members) + :icon :icons/add + :action #(re-frame/dispatch [:navigate-to :add-participants-toggle-list])}]) [{:label (i18n/label :t/clear-history) :icon :icons/close :action #(utils/show-confirmation (i18n/label :t/clear-history-title) @@ -64,16 +62,14 @@ :action #(utils/show-confirmation (i18n/label :t/leave-group-title) (i18n/label :t/leave-group-confirmation) (i18n/label :t/leave-group-action) - (fn [] (re-frame/dispatch [:leave-group-chat]))) + (fn [] (re-frame/dispatch [:remove-chat-and-navigate-home chat-id]))) :accessibility-label :leave-chat-button}])) (defn contact-actions [contact] [{:action #(re-frame/dispatch [:show-profile (:whisper-identity contact)]) :label (i18n/label :t/view-profile)} - ;; NOTE(goranjovic) - group chat participant removal has been temporarily disabled - ;; due to this bug - https://github.com/status-im/status-react/issues/3463 - #_{:action #(re-frame/dispatch [:remove-group-chat-participants #{(:whisper-identity contact)}]) - :label (i18n/label :t/remove-from-chat)}]) + {:action #(re-frame/dispatch [:remove-group-chat-participants #{(:whisper-identity contact)}]) + :label (i18n/label :t/remove-from-chat)}]) (defn render-contact [contact admin?] [react/view diff --git a/src/status_im/utils/contacts.cljs b/src/status_im/utils/contacts.cljs index 0180f5b64f..9039e4e21e 100644 --- a/src/status_im/utils/contacts.cljs +++ b/src/status_im/utils/contacts.cljs @@ -1,9 +1,19 @@ (ns status-im.utils.contacts - (:require - [status-im.utils.identicon :as identicon] - [status-im.utils.gfycat.core :as gfycat])) + (:require [status-im.js-dependencies :as js-dependencies] + [status-im.utils.identicon :as identicon] + [status-im.utils.gfycat.core :as gfycat])) (defn whisper-id->new-contact [whisper-id] {:name (gfycat/generate-gfy whisper-id) :photo-path (identicon/identicon whisper-id) :whisper-identity whisper-id}) + +(defn public-key->address [public-key] + (let [length (count public-key) + normalized-key (case length + 132 (subs public-key 4) + 130 (subs public-key 2) + 128 public-key + nil)] + (when normalized-key + (subs (.sha3 js-dependencies/Web3.prototype normalized-key #js {:encoding "hex"}) 26)))) diff --git a/test/cljs/status_im/test/chat/events.cljs b/test/cljs/status_im/test/chat/events.cljs index a29d16cdcc..68defff544 100644 --- a/test/cljs/status_im/test/chat/events.cljs +++ b/test/cljs/status_im/test/chat/events.cljs @@ -17,14 +17,13 @@ (deftest init-console-chat (testing "initialising console if console is already added to chats, should not modify anything" (let [db {:chats {const/console-chat-id console-chat/chat}} - fx (chat-events/init-console-chat db)] - (is (= db (:db fx))) - (is (= #{:db} (-> fx keys set))))) + fx (chat-events/init-console-chat {:db db})] + (is (not fx)))) (testing "initialising console without existing account and console chat not initialisated" (let [fresh-db {:chats {} :accounts/current-account-id nil} - {:keys [db dispatch-n]} (chat-events/init-console-chat fresh-db)] + {:keys [db dispatch-n]} (chat-events/init-console-chat {:db fresh-db})] (is (= (:current-chat-id db) (:chat-id console-chat/chat))) (is (= (:current-chat-id db) @@ -33,7 +32,7 @@ (testing "initialising console with existing account and console chat not initialisated" (let [fresh-db {:chats {} :accounts/current-account-id (:whisper-identity contact)} - {:keys [db dispatch-n]} (chat-events/init-console-chat fresh-db)] + {:keys [db dispatch-n]} (chat-events/init-console-chat {:db fresh-db})] (is (= (:current-chat-id db) (:chat-id console-chat/chat))) (is (= (:current-chat-id db) diff --git a/test/cljs/status_im/test/chat/models/input.cljs b/test/cljs/status_im/test/chat/models/input.cljs index 4738c65ed0..dbbe29e936 100644 --- a/test/cljs/status_im/test/chat/models/input.cljs +++ b/test/cljs/status_im/test/chat/models/input.cljs @@ -8,19 +8,17 @@ #{"0x1" :group-chats :anonymous :dapps} {:command {"command2" ["0x1" :command 4 "command2"]}} #{"0x2" :personal-chats :anonymous :dapps} {:command {"command3" ["0x2" :command 2 "command3"]}} #{"0x2" :group-chats :anonymous :dapps} {:response {"response1" ["0x2" :response 4 "response1"]}}} - :chats {"test1" {:contacts [{:identity "0x1"}] + :chats {"test1" {:contacts ["0x1"] :requests nil :seq-arguments ["arg1" "arg2"]} - "test2" {:contacts [{:identity "0x1"} - {:identity "0x2"}] + "test2" {:contacts ["0x1" "0x2"] :group-chat true :requests {"id1" {:message-id "id1" :response "response1"}}} - "test3" {:contacts [{:identity "0x1"}] + "test3" {:contacts ["0x1"] :requests {"id1" {:message-id "id1" :response "request1"}}} - "test4" {:contacts [{:identity "0x1"} - {:identity "0x2"}] + "test4" {:contacts ["0x1" "0x2"] :group-chat true :requests {"id2" {:message-id "id2" :response "response1"}}