[perf] upgrade realm and improve schemas/queries

- upgrade to realm 2.28 to benefit from perf improvements
- remove user-statuses and replace by seen and outgoing-status fields
to get rid of a lot of bloat queries and computations
- remove unused seen message, bottom-infos
- remove unused fields in transport schema
- use objectForPrimaryKey whenever possible instead of get by field

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
yenda 2019-06-02 04:22:56 +02:00
parent b3df9d4952
commit 1ae42ea424
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
28 changed files with 390 additions and 580 deletions

View File

@ -65,7 +65,7 @@
"react-native-webview": "^5.2.1",
"react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#fix/classnames-colision",
"react-navigation": "^2.12.1",
"realm": "^2.26.1",
"realm": "2.28.0",
"rn-snoopy": "git+https://github.com/status-im/rn-snoopy.git#v2.0.2-status",
"string_decoder": "0.10.31",
"text-encoding": "^0.6.4",

View File

@ -1167,9 +1167,9 @@ agent-base@^4.1.0:
es6-promisify "^5.0.0"
ajv@^6.5.5:
version "6.7.0"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.7.0.tgz#e3ce7bb372d6577bb1839f1dfdfcbf5ad2948d96"
integrity sha512-RZXPviBTtfmtka9n9sy1N5M5b82CbxWIR6HIis4s3WQTXDJamc/0gpCWNGz6EWdWp4DOfjzJfhz/AS9zVPjjWg==
version "6.10.0"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.0.tgz#90d0d54439da587cd7e843bfb7045f50bd22bdf1"
integrity sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==
dependencies:
fast-deep-equal "^2.0.1"
fast-json-stable-stringify "^2.0.0"
@ -1993,9 +1993,9 @@ color-support@^1.1.3:
integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==
combined-stream@^1.0.6, combined-stream@~1.0.6:
version "1.0.7"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828"
integrity sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
dependencies:
delayed-stream "~1.0.0"
@ -2267,14 +2267,14 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"
debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3:
debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
dependencies:
ms "2.0.0"
debug@^3.1.0:
debug@^3.1.0, debug@^3.2.6:
version "3.2.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==
@ -3087,9 +3087,9 @@ fs-extra@^7.0.1:
universalify "^0.1.0"
fs-minipass@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d"
integrity sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==
version "1.2.6"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.6.tgz#2c5cc30ded81282bfe8a0d7c7c1853ddeb102c07"
integrity sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==
dependencies:
minipass "^2.2.1"
@ -3188,7 +3188,7 @@ glob-parent@^2.0.0:
dependencies:
is-glob "^2.0.0"
glob@^7.1.1, glob@^7.1.3:
glob@^7.1.1:
version "7.1.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1"
integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==
@ -3200,6 +3200,18 @@ glob@^7.1.1, glob@^7.1.3:
once "^1.3.0"
path-is-absolute "^1.0.0"
glob@^7.1.3:
version "7.1.4"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255"
integrity sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
global@^4.3.0, global@~4.3.0:
version "4.3.2"
resolved "https://registry.yarnpkg.com/global/-/global-4.3.2.tgz#e76989268a6c74c38908b1305b10fc0e394e9d0f"
@ -3447,9 +3459,9 @@ iconv-lite@^0.4.17, iconv-lite@^0.4.4, iconv-lite@~0.4.13:
resolved "git+https://github.com/status-im/identicon.js.git#4cd179daaf6f01384502b4b2c1876f982db0f57e"
ieee754@^1.1.4:
version "1.1.12"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.12.tgz#50bf24e5b9c8bb98af4964c941cdb0918da7b60b"
integrity sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==
version "1.1.13"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84"
integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==
ignore-walk@^3.0.1:
version "3.0.1"
@ -4075,7 +4087,7 @@ lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0,
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1, loose-envify@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
@ -4477,6 +4489,11 @@ miller-rabin@^4.0.0:
bn.js "^4.0.0"
brorand "^1.0.1"
mime-db@1.40.0:
version "1.40.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.40.0.tgz#a65057e998db090f732a68f6c276d387d4126c32"
integrity sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==
"mime-db@>= 1.36.0 < 2", mime-db@~1.37.0:
version "1.37.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8"
@ -4494,7 +4511,14 @@ mime-types@2.1.11:
dependencies:
mime-db "~1.23.0"
mime-types@^2.1.12, mime-types@~2.1.18, mime-types@~2.1.19:
mime-types@^2.1.12, mime-types@~2.1.19:
version "2.1.24"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.24.tgz#b6f8d0b3e951efb77dedeca194cff6d16f676f81"
integrity sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==
dependencies:
mime-db "1.40.0"
mime-types@~2.1.18:
version "2.1.21"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.21.tgz#28995aa1ecb770742fe6ae7e58f9181c744b3f96"
integrity sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==
@ -4560,7 +4584,7 @@ minimist@~0.0.1:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=
minipass@^2.2.1, minipass@^2.3.4:
minipass@^2.2.1, minipass@^2.3.5:
version "2.3.5"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.5.tgz#cacebe492022497f656b0f0f51e2682a9ed2d848"
integrity sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==
@ -4568,7 +4592,7 @@ minipass@^2.2.1, minipass@^2.3.4:
safe-buffer "^5.1.2"
yallist "^3.0.0"
minizlib@^1.1.1:
minizlib@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.2.1.tgz#dd27ea6136243c7c880684e8672bb3a45fd9b614"
integrity sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==
@ -4621,7 +4645,12 @@ nan@2.10.0:
resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f"
integrity sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==
nan@^2.12.1, nan@^2.9.2:
nan@^2.12.1:
version "2.14.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
nan@^2.9.2:
version "2.12.1"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552"
integrity sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==
@ -4649,11 +4678,11 @@ nanomatch@^1.2.9:
to-regex "^3.0.1"
needle@^2.2.1:
version "2.2.4"
resolved "https://registry.yarnpkg.com/needle/-/needle-2.2.4.tgz#51931bff82533b1928b7d1d69e01f1b00ffd2a4e"
integrity sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA==
version "2.4.0"
resolved "https://registry.yarnpkg.com/needle/-/needle-2.4.0.tgz#6833e74975c444642590e15a750288c5f939b57c"
integrity sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==
dependencies:
debug "^2.1.2"
debug "^3.2.6"
iconv-lite "^0.4.4"
sax "^1.2.4"
@ -4686,9 +4715,9 @@ node-int64@^0.4.0:
integrity sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=
node-machine-id@^1.1.10:
version "1.1.10"
resolved "https://registry.yarnpkg.com/node-machine-id/-/node-machine-id-1.1.10.tgz#b4cb8f01b25b90d4e0675be00df30e61ee75179b"
integrity sha512-6SVxo3Ic2Qc09z1rCJh3No7ubizPLszImsMQnZZWfzeOC6SYU4orN214++c3ikB8uaP/A6dwSlO88A3ohI5oNA==
version "1.1.12"
resolved "https://registry.yarnpkg.com/node-machine-id/-/node-machine-id-1.1.12.tgz#37904eee1e59b320bb9c5d6c0a59f3b469cb6267"
integrity sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==
node-modules-regexp@^1.0.0:
version "1.0.0"
@ -4770,14 +4799,14 @@ normalize-path@^2.0.1, normalize-path@^2.1.1:
remove-trailing-separator "^1.0.1"
npm-bundled@^1.0.1:
version "1.0.5"
resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.5.tgz#3c1732b7ba936b3a10325aef616467c0ccbcc979"
integrity sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g==
version "1.0.6"
resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.6.tgz#e7ba9aadcef962bb61248f91721cd932b3fe6bdd"
integrity sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==
npm-packlist@^1.1.6:
version "1.2.0"
resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.2.0.tgz#55a60e793e272f00862c7089274439a4cc31fc7f"
integrity sha512-7Mni4Z8Xkx0/oegoqlcao/JpPCPEMtUvsmB0q7mgvlMinykJLSRTYuFqoQLYgGY8biuxIeiHO+QNJKbCfljewQ==
version "1.4.1"
resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.1.tgz#19064cdf988da80ea3cee45533879d90192bbfbc"
integrity sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==
dependencies:
ignore-walk "^3.0.1"
npm-bundled "^1.0.1"
@ -5220,7 +5249,7 @@ prop-types@15.6.0:
loose-envify "^1.3.1"
object-assign "^4.1.1"
prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2:
prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1:
version "15.6.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
integrity sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ==
@ -5228,6 +5257,15 @@ prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1,
loose-envify "^1.3.1"
object-assign "^4.1.1"
prop-types@^15.6.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
dependencies:
loose-envify "^1.4.0"
object-assign "^4.1.1"
react-is "^16.8.1"
property-information@^5.0.0, property-information@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/property-information/-/property-information-5.0.1.tgz#c3b09f4f5750b1634c0b24205adbf78f18bdf94f"
@ -5249,9 +5287,9 @@ pseudomap@^1.0.2:
integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM=
psl@^1.1.24:
version "1.1.31"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.31.tgz#e9aa86d0101b5b105cbe93ac6b784cd547276184"
integrity sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==
version "1.1.32"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.32.tgz#3f132717cf2f9c169724b2b6caf373cf694198db"
integrity sha512-MHACAkHpihU/REGGPLj4sEfc/XKW2bheigvHO1dUqjaKigMp1C8+WLQYRGgeKFMsw5PMfegZcaN8IDXK/cD0+g==
public-encrypt@^4.0.0:
version "4.0.3"
@ -5299,9 +5337,9 @@ qs@6.5.2, qs@~6.5.2:
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
qs@^6.1.0:
version "6.6.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.6.0.tgz#a99c0f69a8d26bf7ef012f871cdabb0aee4424c2"
integrity sha512-KIJqT9jQJDQx5h5uAVPimw6yVg2SekOKu959OCtktD3FjzbpvaPr8i4zzg07DOMz+igA4W/aNM7OV8H37pFYfA==
version "6.7.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
query-string@^5.0.1:
version "5.1.1"
@ -5330,10 +5368,10 @@ querystring@0.2.0:
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620"
integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=
querystringify@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.0.tgz#7ded8dfbf7879dcc60d0a644ac6754b283ad17ef"
integrity sha512-sluvZZ1YiTLD5jsqZcDmFyV2EwToyXZBfpoVOmktMmW+VEnhgakFHnasVph65fOjGPTWN0Nw3+XQaSeMayr0kg==
querystringify@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.1.tgz#60e5a5fd64a7f8bfa4d2ab2ed6fdf4c85bad154e"
integrity sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==
randomatic@^3.0.0:
version "3.1.1"
@ -5414,6 +5452,11 @@ react-is@^16.5.2:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.7.0.tgz#c1bd21c64f1f1364c6f70695ec02d69392f41bfa"
integrity sha512-Z0VRQdF4NPDoI0tsXVMLkJLiwEBa+RP66g0xDHxgxysxSoCUccSten4RTF/UFvZF1dZvZ9Zu1sx+MDXwcOR34g==
react-is@^16.8.1:
version "16.8.6"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==
react-lifecycles-compat@^3, react-lifecycles-compat@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
@ -5824,10 +5867,10 @@ readable-stream@^2.0.1, readable-stream@^2.0.6, readable-stream@^2.2.2, readable
string_decoder "~1.1.1"
util-deprecate "~1.0.1"
realm@^2.26.1:
version "2.26.1"
resolved "https://registry.yarnpkg.com/realm/-/realm-2.26.1.tgz#9d890c85c4d0946bef0a3ece736551c6a8a5dc49"
integrity sha512-kkDOMV5vgaPOYgTELHFPws9suEF0LI/kSb8SIZ615STKHLHLiRxioxgBcu5beO5HVkjxe5jYx7duSB3NASr+AA==
realm@2.28.0:
version "2.28.0"
resolved "https://registry.yarnpkg.com/realm/-/realm-2.28.0.tgz#e79df5727e3922d507629a7ab079190d984e3bde"
integrity sha512-WvZ497qxQlUAiOxTVPI5/YL1zRlcpvjX26J9NeSs0O4Q5qNEGEP8MnAdrCSOC6zg2GH5vazeW4vla69swEncWA==
dependencies:
command-line-args "^4.0.6"
decompress "^4.2.0"
@ -6139,11 +6182,16 @@ seek-bzip@^1.0.5:
dependencies:
commander "~2.8.1"
"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
version "5.6.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==
semver@^5.3.0:
version "5.7.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b"
integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==
send@0.16.2:
version "0.16.2"
resolved "https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1"
@ -6419,9 +6467,9 @@ sprintf-js@~1.0.2:
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
sshpk@^1.7.0:
version "1.16.0"
resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.0.tgz#1d4963a2fbffe58050aa9084ca20be81741c07de"
integrity sha512-Zhev35/y7hRMcID/upReIvRse+I9SVhyVre/KTJSJQWMz3C3+G+HpO7m1wK/yckEtujKZ7dS4hkVxAnmHaIGVQ==
version "1.16.1"
resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877"
integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==
dependencies:
asn1 "~0.2.3"
assert-plus "^1.0.0"
@ -6600,17 +6648,17 @@ tar-stream@^1.5.2:
xtend "^4.0.0"
tar@^4:
version "4.4.8"
resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.8.tgz#b19eec3fde2a96e64666df9fdb40c5ca1bc3747d"
integrity sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==
version "4.4.9"
resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.9.tgz#058fbb152f6fc45733e84585a40c39e59302e1b3"
integrity sha512-xisFa7Q2i3HOgfn+nmnWLGHD6Tm23hxjkx6wwGmgxkJFr6wxwXnJOdJYcZjL453PSdF0+bemO03+flAzkIdLBQ==
dependencies:
chownr "^1.1.1"
fs-minipass "^1.2.5"
minipass "^2.3.4"
minizlib "^1.1.1"
minipass "^2.3.5"
minizlib "^1.2.1"
mkdirp "^0.5.0"
safe-buffer "^5.1.2"
yallist "^3.0.2"
yallist "^3.0.3"
temp@0.8.3:
version "0.8.3"
@ -6897,11 +6945,11 @@ urix@^0.1.0:
integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=
url-parse@^1.4.4:
version "1.4.4"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.4.4.tgz#cac1556e95faa0303691fec5cf9d5a1bc34648f8"
integrity sha512-/92DTTorg4JjktLNLe6GPS2/RvAd/RGr6LuktmWSMLEOa6rjnlrFXNgSbSmkNvCoL2T028A0a1JaJLzRMlFoHg==
version "1.4.7"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.4.7.tgz#a8a83535e8c00a316e403a5db4ac1b9b853ae278"
integrity sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==
dependencies:
querystringify "^2.0.0"
querystringify "^2.1.1"
requires-port "^1.0.0"
url-set-query@^1.0.0:
@ -7206,7 +7254,7 @@ yallist@^2.1.2:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=
yallist@^3.0.0, yallist@^3.0.2:
yallist@^3.0.0, yallist@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9"
integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==

View File

@ -1,24 +0,0 @@
(ns status-im.chat.core
(:require [status-im.data-store.user-statuses :as user-statuses-store]
[status-im.utils.fx :as fx]))
;; Seen messages
(fx/defn receive-seen
[{:keys [db js-obj dedup-id]} chat-id sender {:keys [message-ids]}]
(when-let [seen-messages-ids (-> (get-in db [:chats chat-id :messages])
(select-keys message-ids)
keys)]
(let [statuses (map (fn [message-id]
{:chat-id chat-id
:message-id message-id
:public-key sender
:status :seen})
seen-messages-ids)]
{:db (reduce (fn [acc {:keys [message-id] :as status}]
(assoc-in acc [:chats chat-id :message-statuses
message-id sender]
status))
db
statuses)
:data-store/tx [{:transaction (user-statuses-store/save-statuses-tx statuses)
:success-event [:message/messages-persisted [(or dedup-id js-obj)]]}]})))

View File

@ -1,13 +1,13 @@
(ns status-im.chat.db
(:require [clojure.set :as clojure.set]
[clojure.string :as string]
[status-im.contact.db :as contact.db]
[status-im.chat.commands.core :as commands]
[status-im.chat.commands.input :as commands.input]
[status-im.contact.db :as contact.db]
[status-im.group-chats.db :as group-chats.db]
[status-im.utils.gfycat.core :as gfycat]
[status-im.mailserver.core :as mailserver]
[status-im.transport.partitioned-topic :as topic]
[status-im.mailserver.core :as mailserver]))
[status-im.utils.gfycat.core :as gfycat]))
(defn group-chat-name
[{:keys [public? name]}]
@ -93,7 +93,7 @@
(= type :gap))
(defn transform-message
[messages message-statuses referenced-messages]
[messages referenced-messages]
(fn [{:keys [message-id timestamp-str] :as reference}]
(if (or (datemark? reference)
(gap? reference))
@ -104,8 +104,7 @@
(quoted-message-data messages referenced-messages))]
(cond-> (-> message
(update :content dissoc :response-to :response-to-v2)
(assoc :timestamp-str timestamp-str
:user-statuses (get message-statuses message-id)))
(assoc :timestamp-str timestamp-str))
;; quoted message reference
quote
(assoc-in [:content :response-to] quote))))))
@ -145,15 +144,15 @@
:value (clojure.string/join (:ids gaps))
:gaps gaps}))
(defn messages-with-datemarks-and-statuses
(defn messages-with-datemarks
"Converts message groups into sequence of messages interspersed with datemarks,
with correct user statuses associated into message"
[message-groups messages message-statuses referenced-messages messages-gaps
[message-groups messages referenced-messages messages-gaps
{:keys [highest-request-to lowest-request-from]} all-loaded? public?]
(transduce
(comp
(mapcat add-datemark)
(map (transform-message messages message-statuses referenced-messages)))
(map (transform-message messages referenced-messages)))
(fn
([]
(let [acc {:messages (list)

View File

@ -5,11 +5,9 @@
[status-im.contact.core :as contact.core]
[status-im.data-store.chats :as chats-store]
[status-im.data-store.messages :as messages-store]
[status-im.data-store.user-statuses :as user-statuses-store]
[status-im.i18n :as i18n]
[status-im.mailserver.core :as mailserver]
[status-im.transport.chat.core :as transport.chat]
[status-im.transport.message.protocol :as protocol]
[status-im.transport.message.public-chat :as public-chat]
[status-im.tribute-to-talk.core :as tribute-to-talk]
[status-im.ui.components.colors :as colors]
@ -17,14 +15,12 @@
[status-im.ui.components.react :as react]
[status-im.ui.screens.navigation :as navigation]
[status-im.utils.clocks :as utils.clocks]
[status-im.utils.config :as config]
[status-im.utils.fx :as fx]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.platform :as platform]
[status-im.utils.priority-map :refer [empty-message-map]]
[status-im.utils.utils :as utils]
[status-im.utils.config :as config]
[status-im.mailserver.core :as mailserver]
[status-im.transport.partitioned-topic :as transport.topic]
[taoensso.timbre :as log]))
(defn- get-chat [cofx chat-id]
@ -191,11 +187,6 @@
(contact-code/stop-listening % chat-id))
(navigation/navigate-to-cofx :home {}))))
(fx/defn send-messages-seen
[{:keys [db] :as cofx} chat-id message-ids]
(when (not (get-in db [:chats chat-id :group-chat]))
(protocol/send (protocol/map->MessagesSeen {:message-ids message-ids}) chat-id cofx)))
(defn- unread-messages-number [chats]
(apply + (map :unviewed-messages-count chats)))
@ -238,26 +229,17 @@
"Marks all unviewed loaded messages as seen in particular chat"
[{:keys [db] :as cofx} chat-id]
(let [public-key (accounts.db/current-public-key cofx)
loaded-unviewed-ids (get-in db [:chats chat-id :loaded-unviewed-messages-ids])
updated-statuses (map (fn [message-id]
{:chat-id chat-id
:message-id message-id
:status-id (str chat-id "-" message-id)
:public-key public-key
:status :seen})
loaded-unviewed-ids)]
loaded-unviewed-ids (get-in db [:chats chat-id :loaded-unviewed-messages-ids])]
(when (seq loaded-unviewed-ids)
(fx/merge cofx
{:db (reduce (fn [acc {:keys [message-id status]}]
(assoc-in acc [:chats chat-id :message-statuses
message-id public-key :status]
status))
{:db (reduce (fn [acc message-id]
(assoc-in acc [:chats chat-id :messages
message-id :seen]
true))
db
updated-statuses)
:data-store/tx [(user-statuses-store/save-statuses-tx updated-statuses)]}
loaded-unviewed-ids)
:data-store/tx [(messages-store/mark-messages-seen-tx loaded-unviewed-ids)]}
(update-chats-unviewed-messages-count {:chat-id chat-id})
;;TODO(rasom): uncomment when seen messages will be revisited
#_(send-messages-seen chat-id loaded-unviewed-ids)
(when platform/desktop?
(update-dock-badge-label))))))

View File

@ -53,16 +53,6 @@
(remove #(some message-id->messages (vals %))))
(vals message-id->messages)))
(defn get-unviewed-messages-ids
[statuses public-key]
(keep
(fn [[message-id statuses]]
(let [{:keys [status]}
(get statuses public-key)]
(when (= (keyword status) :received)
message-id)))
statuses))
(fx/defn update-chats-in-app-db
{:events [:chats-list/load-success]}
[{:keys [db] :as cofx} chats]
@ -118,8 +108,8 @@
"Loads more messages for current chat"
[{{:keys [current-chat-id] :as db} :db
get-stored-messages :get-stored-messages
get-stored-user-statuses :get-stored-user-statuses
get-referenced-messages :get-referenced-messages :as cofx}]
get-referenced-messages :get-referenced-messages
get-unviewed-message-ids :get-unviewed-message-ids :as cofx}]
;; TODO: re-implement functionality for status-go protocol
(when-not (or config/use-status-go-protocol?
(get-in db [:chats current-chat-id :all-loaded?]))
@ -135,14 +125,12 @@
referenced-messages (into empty-message-map
(get-referenced-messages (get-referenced-ids indexed-messages)))
new-message-ids (keys indexed-messages)
new-statuses (get-stored-user-statuses current-chat-id new-message-ids)
public-key (accounts.db/current-public-key cofx)
loaded-unviewed-messages (get-unviewed-messages-ids new-statuses public-key)]
loaded-unviewed-messages (get-unviewed-message-ids)]
(fx/merge cofx
{:db (-> db
(assoc-in [:chats current-chat-id :messages-initialized?] true)
(update-in [:chats current-chat-id :messages] merge indexed-messages)
(update-in [:chats current-chat-id :message-statuses] merge new-statuses)
(update-in [:chats current-chat-id :referenced-messages]
#(into (apply dissoc % new-message-ids) referenced-messages))
(assoc-in [:chats current-chat-id :pagination-info] pagination-info)

View File

@ -9,7 +9,6 @@
[status-im.constants :as constants]
[status-im.contact.db :as contact.db]
[status-im.data-store.messages :as messages-store]
[status-im.data-store.user-statuses :as user-statuses-store]
[status-im.mailserver.core :as mailserver]
[status-im.native-module.core :as status]
[status-im.notifications.core :as notifications]
@ -39,9 +38,9 @@
[{:keys [content content-type] :as message} chat-id current-chat?]
(let [emoji? (message-content/emoji-only-content? content)]
;; TODO janherich: enable the animations again once we can do them more efficiently
(cond-> (assoc message :appearing? true)
(not current-chat?)
(assoc :appearing? false)
(cond-> message
current-chat?
(assoc :seen true)
emoji?
(assoc :content-type constants/content-type-emoji)
@ -73,21 +72,12 @@
(assoc groups new-datemark message-refs))))
{}))}))
(fx/defn add-own-status
[{:keys [db] :as cofx} chat-id message-id status]
(let [me (accounts.db/current-public-key cofx)
status {:chat-id chat-id
:message-id message-id
:public-key me
:status status}]
{:db (assoc-in db
[:chats chat-id :message-statuses message-id me]
status)
:data-store/tx [(user-statuses-store/save-status-tx status)]}))
(defn add-outgoing-status [{:keys [from] :as message} current-public-key]
(assoc message :outgoing (and (= from current-public-key)
(not (system-message? message)))))
(defn add-outgoing-status
[{:keys [from] :as message} current-public-key]
(if (and (= from current-public-key)
(not (system-message? message)))
(assoc message :outgoing true)
message))
(defn build-desktop-notification
[{:keys [db] :as cofx} {:keys [chat-id timestamp content from] :as message}]
@ -145,11 +135,6 @@
(when-not batch?
(chat-loading/group-chat-messages chat-id [message])))))
(fx/defn send-message-seen
[cofx chat-id message-id send-seen?]
(when send-seen?
(protocol/send (protocol/map->MessagesSeen {:message-ids #{message-id}}) chat-id cofx)))
(defn ensure-clock-value [{:keys [clock-value] :as message} {:keys [last-clock-value]}]
(if clock-value
message
@ -170,35 +155,24 @@
old-id->message
{:keys [from message-id chat-id js-obj content dedup-id] :as raw-message}]
(let [{:keys [web3 current-chat-id view-id]} db
current-public-key (accounts.db/current-public-key cofx)
current-chat? (and (or (= :chat view-id)
(= :chat-modal view-id))
(= current-chat-id chat-id))
{:keys [group-chat] :as chat} (get-in db [:chats chat-id])
message (-> raw-message
(commands-receiving/enhance-receive-parameters cofx)
(ensure-clock-value chat)
(check-response-to old-id->message)
;; TODO (cammellos): Refactor so it's not computed twice
(add-outgoing-status current-public-key))]
current-public-key (accounts.db/current-public-key cofx)
current-chat? (and (or (= :chat view-id)
(= :chat-modal view-id))
(= current-chat-id chat-id))
{:keys [group-chat] :as chat} (get-in db [:chats chat-id])
{:keys [outgoing] :as message} (-> raw-message
(commands-receiving/enhance-receive-parameters cofx)
(ensure-clock-value chat)
(check-response-to old-id->message)
;; TODO (cammellos): Refactor so it's not computed twice
(add-outgoing-status current-public-key))]
(fx/merge cofx
(add-message {:batch? true
:message message
:dedup-id dedup-id
:current-chat current-chat?
:raw-message js-obj})
;; Checking :outgoing here only works for now as we don't have a :seen
;; status for public chats, if we add processing of our own messages
;; for 1-to-1 care needs to be taken not to override the :seen status
(add-own-status chat-id message-id (cond (:outgoing message) :sent
current-chat? :seen
:else :received))
(commands-receiving/receive message)
;;TODO(rasom): uncomment when seen messages will be revisited
#_(send-message-seen chat-id message-id (and (not group-chat)
current-chat?
(not (= constants/system from))
(not (:outgoing message)))))))
(commands-receiving/receive message))))
(fx/defn update-group-messages [cofx chat->message chat-id]
(fx/merge cofx
@ -374,7 +348,8 @@
(get-in message [:content :params :coin :icon :source])
(update-in [:content :params :coin] dissoc :icon)))
(fx/defn upsert-and-send [{:keys [now] :as cofx} {:keys [chat-id from] :as message}]
(fx/defn upsert-and-send
[{:keys [now] :as cofx} {:keys [chat-id from] :as message}]
(let [message (remove-icon message)
send-record (protocol/map->Message (select-keys message transport-keys))
old-message-id (transport.utils/old-message-id send-record)
@ -384,6 +359,7 @@
raw-payload (transport.utils/from-utf8 (transit/serialize wrapped-record))
message-id (transport.utils/message-id from raw-payload)
message-with-id (assoc message
:outgoing-status :sending
:message-id message-id
:old-message-id old-message-id
:raw-payload-hash (transport.utils/sha3 raw-payload))]
@ -398,10 +374,10 @@
(add-message {:batch? false
:message message-with-id
:current-chat? true})
(add-own-status chat-id message-id :sending)
(send chat-id message-id wrapped-record))))
(fx/defn send-push-notification [cofx chat-id message-id fcm-tokens status]
(fx/defn send-push-notification
[cofx chat-id message-id fcm-tokens status]
(log/debug "#6772 - send-push-notification" message-id fcm-tokens)
(when (and (seq fcm-tokens) (= status :sent))
(let [payload {:from (accounts.db/current-public-key cofx)
@ -410,17 +386,15 @@
{:send-notification {:data-payload (notifications/encode-notification-payload payload)
:tokens fcm-tokens}})))
(fx/defn update-message-status [{:keys [db]} chat-id message-id status]
(let [from (get-in db [:chats chat-id :messages message-id :from])
updated-status (-> db
(get-in [:chats chat-id :message-statuses message-id from])
(assoc :status status))]
{:db (assoc-in db
[:chats chat-id :message-statuses message-id from]
updated-status)
:data-store/tx [(user-statuses-store/save-status-tx updated-status)]}))
(fx/defn update-message-status
[{:keys [db]} chat-id message-id status]
{:db (assoc-in db
[:chats chat-id :messages message-id :outgoing-status]
status)
:data-store/tx [(messages-store/update-outgoing-status-tx message-id status)]})
(fx/defn resend-message [cofx chat-id message-id]
(fx/defn resend-message
[cofx chat-id message-id]
(let [message (get-in cofx [:db :chats chat-id :messages message-id])
send-record (-> message
(select-keys transport-keys)

View File

@ -15,7 +15,6 @@
(s/def :chat/public-group-topic-error (s/nilable string?))
(s/def :chat/messages (s/nilable map?)) ; messages indexed by message-id
(s/def :chat/message-groups (s/nilable map?)) ; grouped/sorted messages
(s/def :chat/message-statuses (s/nilable map?)) ; message/user statuses indexed by two level index
(s/def :chat/referenced-messages (s/nilable map?)) ; map of messages indexed by message-id which are not displayed directly, but referenced by other messages
(s/def :chat/last-clock-value (s/nilable number?)) ; last logical clock value of messages in chat
(s/def :chat/loaded-chats (s/nilable seq?))

View File

@ -1,6 +1,5 @@
(ns status-im.contact.block
(:require [re-frame.core :as re-frame]
[status-im.accounts.db :as accounts.db]
[status-im.chat.models :as chat.models]
[status-im.chat.models.loading :as chat.models.loading]
[status-im.chat.models.message :as chat.models.message]
@ -16,31 +15,14 @@
{:db (dissoc db :current-chat-id)}
(navigation/navigate-to-clean :home {})))
(defn get-removed-unseen-count
[current-public-key user-statuses removed-messages-ids]
(- (count removed-messages-ids)
(count (filter (fn [[_ statuses]]
(= :seen
(:status (get statuses
current-public-key))))
user-statuses))))
(fx/defn clean-up-chat
[{:keys [db get-stored-user-statuses] :as cofx} chat-id removed-chat-messages]
(let [current-public-key (accounts.db/current-public-key cofx)
removed-messages-ids (map :message-id removed-chat-messages)
user-statuses (get-stored-user-statuses chat-id
removed-messages-ids)
removed-unseen-count (get-removed-unseen-count current-public-key
user-statuses
removed-messages-ids)
[{:keys [db] :as cofx} chat-id removed-chat-messages]
(let [removed-messages-ids (map :message-id removed-chat-messages)
removed-unseen-count (count (remove :seen removed-chat-messages))
db (-> db
;; remove messages
(update-in [:chats chat-id :messages]
#(apply dissoc % removed-messages-ids))
;; remove message statuses
(update-in [:chats chat-id :messages-statuses]
#(apply dissoc % removed-messages-ids))
;; remove message groups
(update-in [:chats chat-id]
dissoc :message-groups))]

View File

@ -53,20 +53,6 @@
(.objects "message")
(.filtered (str "(" (core/in-query "message-id" message-ids) ")")))))
(defn- get-statuses-by-messages-ids
[message-ids]
(when-not (empty message-ids)
(-> @core/account-realm
(.objects "user-status")
(.filtered (str "(" (core/in-query "message-id" message-ids) ")")))))
(defn- get-user-statuses
[public-key]
(core/get-by-field @core/account-realm
:user-status
:public-key
public-key))
(defn- get-chat
[public-key]
(core/single
@ -83,12 +69,6 @@
(when-let [user-messages
(get-messages-by-messages-ids messages-ids)]
(core/delete realm user-messages))
(when-let [user-messages-statuses
(get-statuses-by-messages-ids messages-ids)]
(core/delete realm user-messages-statuses))
(when-let [user-statuses
(get-user-statuses public-key)]
(core/delete realm user-statuses))
(when-let [chat
(get-chat public-key)]
(core/delete realm chat))))

View File

@ -14,9 +14,13 @@
(defn- transform-message
[{:keys [content outgoing-status] :as message}]
(when-let [parsed-content (utils/safe-read-message-content content)]
(-> message
(update :message-type keyword)
(assoc :content parsed-content))))
(let [outgoing-status (when-not (empty? outgoing-status)
(keyword outgoing-status))]
(-> message
(update :message-type keyword)
(assoc :content parsed-content
:outgoing-status outgoing-status
:outgoing outgoing-status)))))
(defn- exclude-messages [query message-ids]
(let [string-queries (map #(str "message-id != \"" % "\"") message-ids)]
@ -105,6 +109,19 @@
(fn [cofx _]
(assoc cofx :get-user-messages get-user-messages)))
(defn get-unviewed-message-ids
[]
(.reduce (core/get-by-field @core/account-realm
:message :seen false)
(fn [acc message-object _ _]
(aget message-object "message-id"))
[]))
(re-frame/reg-cofx
:data-store/get-unviewed-message-ids
(fn [cofx _]
(assoc cofx :get-unviewed-message-ids get-unviewed-message-ids)))
(defn prepare-content [content]
(if (string? content)
content
@ -140,3 +157,25 @@
(if @core/account-realm
(not (nil? (get-message-by-id message-id @core/account-realm)))
false))
(defn mark-messages-seen-tx
"Returns tx function for marking messages as seen"
[message-ids]
(fn [realm]
(doseq [message-id message-ids]
(let [message (get-message-by-id message-id realm)]
(aset message "seen" true)))))
(defn mark-message-seen-tx
"Returns tx function for marking messages as seen"
[message-id]
(fn [realm]
(let [message (get-message-by-id message-id realm)]
(aset message "seen" true))))
(defn update-outgoing-status-tx
"Returns tx function for marking messages as seen"
[message-id outgoing-status]
(fn [realm]
(let [message (get-message-by-id message-id realm)]
(aset message "outgoing-status" (name outgoing-status)))))

View File

@ -545,6 +545,21 @@
contact-recovery/v1
mailserver-requests-gap/v1])
(def v46 [chat/v15
chat-requests-range/v1
transport/v9
contact/v8
message/v11
mailserver/v11
mailserver-topic/v2
membership-update/v1
installation/v3
browser/v8
dapp-permissions/v9
contact-device-info/v1
contact-recovery/v1
mailserver-requests-gap/v1])
;; put schemas ordered by version
(def schemas [{:schema v1
:schemaVersion 1
@ -680,4 +695,7 @@
:migration (constantly nil)}
{:schema v45
:schemaVersion 45
:migration (constantly nil)}])
:migration (constantly nil)}
{:schema v46
:schemaVersion 46
:migration migrations/v46}])

View File

@ -68,3 +68,13 @@
(assoc-in [:properties :whisper-timestamp]
{:type :int
:optional true})))
(def v11
(-> v10
(update :properties dissoc :outgoing)
(assoc-in [:properties :seen]
{:type :bool
:default false})
(assoc-in [:properties :outgoing-status]
{:type :string
:optional true})))

View File

@ -38,10 +38,7 @@
(js-delete (aget messages i) "user-statuses"))))
(defn message-by-id [realm message-id]
(some-> realm
(.objects "message")
(.filtered (str "message-id = \"" message-id "\""))
(aget 0)))
(.objectForPrimaryKey realm "message" message-id))
(defn v8 [old-realm new-realm]
(log/debug "migrating v8 account database")
@ -417,3 +414,19 @@
(when mailserver-topic
(aset mailserver-topic "chat-ids" chat-ids-str))))
(defn v46
"Migrate user-statuses"
[old-realm new-realm]
(log/debug "migrating v46 account database")
(let [old-user-statuses (.objects old-realm "user-status")]
(dotimes [i (.-length old-user-statuses)]
(let [user-status (aget old-user-statuses i)
status (aget user-status "status")
message-id (aget user-status "message-id")
message (message-by-id new-realm message-id)]
(cond
(= status "seen")
(aset message "seen" true)
(#{"sent" "sending" "not-sent"} status)
(aset message "outgoing-status" status))))))

View File

@ -1,46 +0,0 @@
(ns status-im.data-store.user-statuses
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.data-store.realm.core :as core]))
(defn- prepare-statuses [statuses]
(reduce (fn [acc {:keys [message-id public-key] :as user-status}]
(assoc-in acc
[message-id public-key]
(-> user-status
(update :status keyword)
(dissoc :status-id))))
{}
statuses))
(defn- get-by-chat-and-messages-ids
[chat-id message-ids]
(-> @core/account-realm
(.objects "user-status")
(.filtered (str "chat-id=\"" chat-id "\""
(when (seq message-ids)
(str " and (" (core/in-query "message-id" message-ids) ")"))))
(core/all-clj :user-status)
prepare-statuses))
(re-frame/reg-cofx
:data-store/get-user-statuses
(fn [cofx _]
(assoc cofx :get-stored-user-statuses get-by-chat-and-messages-ids)))
(defn- compute-status-id [{:keys [message-id public-key]}]
(str message-id "-" public-key))
(defn save-status-tx
"Returns tx function for saving message user status"
[user-status]
(fn [realm]
(let [status-id (compute-status-id user-status)]
(core/create realm :user-status (assoc user-status :status-id status-id) true))))
(defn save-statuses-tx
"Returns tx function for saving message user statuses"
[user-statuses]
(fn [realm]
(doseq [user-status user-statuses]
((save-status-tx user-status) realm))))

View File

@ -803,12 +803,6 @@
(fn [cofx [_ chat-id]]
(chat/join-time-messages-checked cofx chat-id)))
(handlers/register-handler-fx
:chat.ui/show-message-details
(fn [{:keys [db]} [_ details]]
{:db (chat/set-chat-ui-props db {:show-bottom-info? true
:bottom-info details})}))
(handlers/register-handler-fx
:chat.ui/show-message-options
(fn [{:keys [db]} [_ options]]
@ -823,8 +817,8 @@
(handlers/register-handler-fx
:chat.ui/load-more-messages
[(re-frame/inject-cofx :data-store/get-messages)
(re-frame/inject-cofx :data-store/get-user-statuses)
(re-frame/inject-cofx :data-store/get-referenced-messages)
(re-frame/inject-cofx :data-store/get-unviewed-message-ids)
(re-frame/inject-cofx :data-store/all-gaps)]
(fn [cofx _]
(chat.loading/load-more-messages cofx)))
@ -1736,8 +1730,7 @@
(handlers/register-handler-fx
:contact.ui/block-contact-confirmed
[(re-frame/inject-cofx :data-store/get-user-messages)
(re-frame/inject-cofx :data-store/get-user-statuses)]
[(re-frame/inject-cofx :data-store/get-user-messages)]
(fn [cofx [_ public-key]]
(contact.block/block-contact cofx public-key)))

View File

@ -594,12 +594,6 @@
(fn [{:keys [message-groups]}]
(or message-groups {})))
(re-frame/reg-sub
:chats/current-chat-message-statuses
:<- [:chats/current-chat]
(fn [{:keys [message-statuses]}]
(or message-statuses {})))
(re-frame/reg-sub
:chats/current-chat-referenced-messages
:<- [:chats/current-chat]
@ -636,17 +630,16 @@
:chats/current-chat-messages-stream
:<- [:chats/current-chat-messages]
:<- [:chats/current-chat-message-groups]
:<- [:chats/current-chat-message-statuses]
:<- [:chats/current-chat-referenced-messages]
:<- [:chats/messages-gaps]
:<- [:chats/range]
:<- [:chats/all-loaded?]
:<- [:chats/public?]
(fn [[messages message-groups message-statuses referenced-messages
(fn [[messages message-groups referenced-messages
messages-gaps range all-loaded? public?]]
(-> (chat.db/sort-message-groups message-groups messages)
(chat.db/messages-with-datemarks-and-statuses
messages message-statuses referenced-messages
(chat.db/messages-with-datemarks
messages referenced-messages
messages-gaps range all-loaded? public?)
chat.db/messages-stream)))

View File

@ -1,15 +1,15 @@
(ns ^{:doc "Definition of the StatusMessage protocol"}
status-im.transport.message.core
(:require [re-frame.core :as re-frame]
[goog.object :as o]
(:require [goog.object :as o]
[re-frame.core :as re-frame]
[status-im.chat.models.message :as models.message]
[status-im.utils.config :as config]
[status-im.contact.device-info :as device-info]
[status-im.data-store.transport :as transport-store]
[status-im.transport.message.contact :as contact]
[status-im.transport.message.protocol :as protocol]
[status-im.transport.message.transit :as transit]
[status-im.transport.utils :as transport.utils]
[status-im.contact.device-info :as device-info]
[status-im.utils.config :as config]
[status-im.utils.fx :as fx]
[taoensso.timbre :as log]))
@ -80,19 +80,27 @@
{:db (assoc-in db [:transport/chats chat-id :resend?] nil)
:data-store/tx [(transport-store/save-transport-tx {:chat-id chat-id
:chat updated-chat})]}))
(fx/defn check-confirmations [{:keys [db] :as cofx} status chat-id message-id]
(fx/defn check-confirmations
[{:keys [db] :as cofx} status chat-id message-id]
(when-let [{:keys [pending-confirmations not-sent]}
(get-in db [:transport/message-ids->confirmations message-id])]
(if (zero? (dec pending-confirmations))
(fx/merge cofx
{:db (update db :transport/message-ids->confirmations dissoc message-id)}
(models.message/update-message-status chat-id message-id (if not-sent
:not-sent
status)))
{:db (update db
:transport/message-ids->confirmations
dissoc message-id)}
(models.message/update-message-status chat-id
message-id
(if not-sent
:not-sent
status)))
(let [confirmations {:pending-confirmations (dec pending-confirmations)
:not-sent (or not-sent
(= :not-sent status))}]
{:db (assoc-in db [:transport/message-ids->confirmations message-id] confirmations)}))))
{:db (assoc-in db
[:transport/message-ids->confirmations message-id]
confirmations)}))))
(fx/defn update-envelope-status
[{:keys [db] :as cofx} envelope-hash status]

View File

@ -2,7 +2,6 @@
status-im.transport.message.protocol
(:require [cljs.spec.alpha :as spec]
[status-im.accounts.db :as accounts.db]
[status-im.chat.core :as chat]
[status-im.transport.db :as transport.db]
[status-im.transport.partitioned-topic :as transport.topic]
[status-im.transport.utils :as transport.utils]
@ -137,14 +136,3 @@
(if (spec/valid? :message/message this)
this
(log/warn "failed to validate Message" (spec/explain-str :message/message this)))))
(defrecord MessagesSeen [message-ids]
StatusMessage
(send [this chat-id cofx]
(send-with-pubkey cofx {:chat-id chat-id
:payload this}))
(receive [this chat-id signature _ cofx]
(chat/receive-seen cofx chat-id signature this))
(validate [this]
(when (spec/valid? :message/message-seen this)
this)))

View File

@ -71,12 +71,6 @@
;; no need for legacy conversions for rest of the content types
#js [content content-type message-type clock-value timestamp])))
(deftype MessagesSeenHandler []
Object
(tag [this v] "c5")
(rep [this {:keys [message-ids]}]
(clj->js message-ids)))
(deftype GroupMembershipUpdateHandler []
Object
(tag [this v] "g5")
@ -101,7 +95,6 @@
contact/ContactRequestConfirmed (ContactRequestConfirmedHandler.)
contact/ContactUpdate (ContactUpdateHandler.)
protocol/Message (MessageHandler.)
protocol/MessagesSeen (MessagesSeenHandler.)
group-chat/GroupMembershipUpdate (GroupMembershipUpdateHandler.)
pairing/SyncInstallation (SyncInstallationHandler.)
pairing/PairInstallation (PairInstallationHandler.)}}))
@ -148,8 +141,7 @@
(protocol/Message. new-content new-content-type message-type clock-value timestamp)))
"c7" (fn [[content content-type message-type clock-value timestamp]]
(protocol/Message. content content-type message-type clock-value timestamp))
"c5" (fn [message-ids]
(protocol/MessagesSeen. message-ids))
"c5" (fn [])
"c6" (fn [[name profile-image address fcm-token device-info]]
(contact/ContactUpdate. name profile-image address fcm-token device-info))
"g5" (fn [[chat-id membership-updates message]]

View File

@ -1,32 +1,27 @@
(ns status-im.ui.screens.chat.bottom-info
(:require-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :as re-frame]
[reagent.core :as reagent]
[clojure.string :as string]
[status-im.ui.components.react :as react]
[status-im.ui.screens.chat.styles.main :as styles]
[status-im.i18n :as i18n]
(:require [reagent.core :as reagent]
[status-im.ui.components.animation :as anim]
[status-im.ui.components.list.views :as list]
[status-im.ui.screens.chat.photos :as photos]
[status-im.utils.core :as utils]
[status-im.utils.identicon :as identicon]))
[status-im.ui.components.react :as react]
[status-im.ui.screens.chat.styles.main :as styles]))
(defn- container-animation-logic [{:keys [to-value val]}]
(defn- container-animation-logic
[{:keys [to-value val]}]
(fn [_]
(anim/start
(anim/spring val {:toValue to-value
:friction 6
:tension 40}))))
(defn overlay [{:keys [on-click-outside]} items]
(defn overlay
[{:keys [on-click-outside]} items]
[react/view styles/bottom-info-overlay
[react/touchable-highlight {:on-press on-click-outside
:style styles/overlay-highlight}
[react/view nil]]
items])
(defn container [height & _]
(defn container
[height & _]
(let [anim-value (anim/create-value 1)
context {:to-value height
:val anim-value}
@ -39,45 +34,3 @@
(fn [height & children]
[react/animated-view {:style (styles/bottom-info-container height)}
(into [react/view] children)])})))
(defn- message-status-row [{:keys [photo-path name]} {:keys [public-key status]}]
[react/view styles/bottom-info-row
[photos/photo
(or photo-path (identicon/identicon public-key))
styles/bottom-info-row-photo-size]
[react/view styles/bottom-info-row-text-container
[react/text {:style styles/bottom-info-row-text1
:number-of-lines 1}
(utils/truncate-str (if-not (string/blank? name)
name
public-key) 30)]
[react/text {:style styles/bottom-info-row-text2
:number-of-lines 1}
(i18n/message-status-label (or status :sending))]]])
(defn- render-status [contacts]
(fn [{:keys [public-key] :as row} _ _]
(let [contact (get contacts public-key)]
[message-status-row contact row])))
(defn bottom-info-view []
(let [bottom-info (re-frame/subscribe [:chats/current-chat-ui-prop :bottom-info])
contacts (re-frame/subscribe [:contacts/contacts])]
(reagent/create-class
{:display-name "bottom-info-view"
:reagent-render
(fn []
(let [{:keys [user-statuses message-status participants]} @bottom-info
participants (->> participants
(map (fn [{:keys [identity]}]
[identity {:public-key identity
:status message-status}]))
(into {}))
statuses (vals (merge participants user-statuses))]
[overlay {:on-click-outside #(re-frame/dispatch [:chat.ui/set-chat-ui-props {:show-bottom-info? false}])}
[container (* styles/item-height (count statuses))
[list/flat-list {:contentContainerStyle styles/bottom-info-list-container
:data statuses
:key-fn :address
:render-fn (render-status @contacts)
:enableEmptySections true}]]]))})))

View File

@ -1,30 +1,28 @@
(ns status-im.ui.screens.chat.message.message
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [re-frame.core :as re-frame]
[status-im.ui.components.react :as react]
[status-im.ui.components.list-selection :as list-selection]
[status-im.ui.components.icons.vector-icons :as vector-icons]
[status-im.ui.components.action-sheet :as action-sheet]
[status-im.chat.commands.core :as commands]
[status-im.chat.commands.receiving :as commands-receiving]
[status-im.ui.screens.chat.styles.message.message :as style]
[status-im.ui.screens.chat.photos :as photos]
[status-im.ui.components.popup-menu.views :as desktop.pop-up]
[status-im.constants :as constants]
[status-im.ui.screens.chat.utils :as chat.utils]
[status-im.utils.identicon :as identicon]
[status-im.utils.platform :as platform]
[status-im.i18n :as i18n]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.icons.vector-icons :as icons]
[status-im.chat.commands.protocol :as protocol]
[status-im.extensions.core :as extensions]))
[status-im.chat.commands.receiving :as commands-receiving]
[status-im.constants :as constants]
[status-im.extensions.core :as extensions]
[status-im.i18n :as i18n]
[status-im.ui.components.action-sheet :as action-sheet]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.icons.vector-icons :as vector-icons]
[status-im.ui.components.list-selection :as list-selection]
[status-im.ui.components.popup-menu.views :as desktop.pop-up]
[status-im.ui.components.react :as react]
[status-im.ui.screens.chat.photos :as photos]
[status-im.ui.screens.chat.styles.message.message :as style]
[status-im.ui.screens.chat.utils :as chat.utils]
[status-im.utils.platform :as platform])
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
(defn install-extension-message [extension-id outgoing]
[react/touchable-highlight {:on-press #(re-frame/dispatch
[:extensions.ui/install-extension-button-pressed extension-id])}
[react/view style/extension-container
[icons/icon :main-icons/info {:color (if outgoing colors/white colors/gray)}]
[vector-icons/icon :main-icons/info {:color (if outgoing colors/white colors/gray)}]
[react/text {:style (style/extension-text outgoing)}
(i18n/label :to-see-this-message)]
[react/text {:style (style/extension-install outgoing)}
@ -155,54 +153,33 @@
[react/text {:style style/delivery-text}
(i18n/message-status-label status)]])
(defview group-message-delivery-status [{:keys [message-id current-public-key user-statuses] :as msg}]
(letsubs [{participants :contacts} [:chats/current-chat]
contacts [:contacts/contacts]]
(let [outgoing-status (or (get-in user-statuses [current-public-key :status]) :sending)
delivery-statuses (dissoc user-statuses current-public-key)
delivery-statuses-count (count delivery-statuses)
seen-by-everyone (and (= delivery-statuses-count (count participants))
(every? (comp (partial = :seen) :status second) delivery-statuses)
:seen-by-everyone)]
(if (or seen-by-everyone (zero? delivery-statuses-count))
[text-status (or seen-by-everyone outgoing-status)]
[react/touchable-highlight
{:on-press #(re-frame/dispatch [:chat.ui/show-message-details {:message-status outgoing-status
:user-statuses delivery-statuses
:participants participants}])}
[react/view style/delivery-view
(for [[public-key] (take 3 delivery-statuses)]
^{:key public-key}
[react/image {:source {:uri (or (get-in contacts [public-key :photo-path])
(identicon/identicon public-key))}
:style {:width 16
:height 16
:border-radius 8}}])
(if (> delivery-statuses-count 3)
[react/text {:style style/delivery-text}
(str "+ " (- delivery-statuses-count 3))])]]))))
(defn message-activity-indicator []
(defn message-activity-indicator
[]
[react/view style/message-activity-indicator
[react/activity-indicator {:animating true}]])
(defn message-not-sent-text [chat-id message-id]
[react/touchable-highlight {:on-press (fn [] (cond
platform/ios?
(action-sheet/show {:title (i18n/label :message-not-sent)
:options [{:label (i18n/label :resend-message)
:action #(re-frame/dispatch [:chat.ui/resend-message chat-id message-id])}
{:label (i18n/label :delete-message)
:destructive? true
:action #(re-frame/dispatch [:chat.ui/delete-message chat-id message-id])}]})
platform/desktop?
(desktop.pop-up/show-desktop-menu
(desktop.pop-up/get-message-menu-items chat-id message-id))
(defn message-not-sent-text
[chat-id message-id]
[react/touchable-highlight
{:on-press (fn [] (cond
platform/ios?
(action-sheet/show
{:title (i18n/label :message-not-sent)
:options [{:label (i18n/label :resend-message)
:action #(re-frame/dispatch
[:chat.ui/resend-message chat-id message-id])}
{:label (i18n/label :delete-message)
:destructive? true
:action #(re-frame/dispatch
[:chat.ui/delete-message chat-id message-id])}]})
platform/desktop?
(desktop.pop-up/show-desktop-menu
(desktop.pop-up/get-message-menu-items chat-id message-id))
:else
(re-frame/dispatch
[:chat.ui/show-message-options {:chat-id chat-id
:message-id message-id}])))}
:else
(re-frame/dispatch
[:chat.ui/show-message-options {:chat-id chat-id
:message-id message-id}])))}
[react/view style/not-sent-view
[react/text {:style style/not-sent-text}
(i18n/message-status-label (if platform/desktop?
@ -221,22 +198,18 @@
[vector-icons/icon :main-icons/warning {:color colors/red}]]])))
(defn message-delivery-status
[{:keys [chat-id message-id current-public-key user-statuses content last-outgoing? outgoing message-type] :as message}]
(let [outgoing-status (or (get-in user-statuses [current-public-key :status]) :not-sent)
delivery-status (get-in user-statuses [chat-id :status])
status (or delivery-status outgoing-status)]
(when (not= :system-message message-type)
(case status
:sending [message-activity-indicator]
:not-sent [message-not-sent-text chat-id message-id]
(if (and (not outgoing)
(:command content))
[command-status content]
(when last-outgoing?
(if (= message-type :group-user-message)
[group-message-delivery-status message]
(if outgoing
[text-status status]))))))))
[{:keys [chat-id message-id outgoing-status
content last-outgoing? message-type] :as message}]
(when (not= :system-message message-type)
(case outgoing-status
:sending [message-activity-indicator]
:not-sent [message-not-sent-text chat-id message-id]
(if (and (not outgoing-status)
(:command content))
[command-status content]
(when last-outgoing?
(if outgoing-status
[text-status outgoing-status]))))))
(defview message-author-name [from message-username]
(letsubs [username [:contacts/contact-name-by-identity from]]
@ -271,20 +244,23 @@
[{:keys [message-id old-message-id content] :as message}]
(list-selection/chat-message message-id old-message-id (:text content) (i18n/label :t/message)))
(defn chat-message [{:keys [outgoing group-chat modal? current-public-key content-type content] :as message}]
(defn chat-message
[{:keys [outgoing group-chat modal? current-public-key content-type content] :as message}]
[react/view
[react/touchable-highlight {:on-press (fn [arg]
(if (and platform/desktop? (= "right" (.-button (.-nativeEvent arg))))
(open-chat-context-menu message)
(do
(when (= content-type constants/content-type-sticker)
(re-frame/dispatch [:stickers/open-sticker-pack (:pack content)]))
(re-frame/dispatch [:chat.ui/set-chat-ui-props {:messages-focused? true
:show-stickers? false}])
(when-not platform/desktop?
(react/dismiss-keyboard!)))))
:on-long-press #(when (or (= content-type constants/content-type-text) (= content-type constants/content-type-emoji))
(open-chat-context-menu message))}
[react/touchable-highlight
{:on-press (fn [arg]
(if (and platform/desktop? (= "right" (.-button (.-nativeEvent arg))))
(open-chat-context-menu message)
(do
(when (= content-type constants/content-type-sticker)
(re-frame/dispatch [:stickers/open-sticker-pack (:pack content)]))
(re-frame/dispatch [:chat.ui/set-chat-ui-props {:messages-focused? true
:show-stickers? false}])
(when-not platform/desktop?
(react/dismiss-keyboard!)))))
:on-long-press #(when (or (= content-type constants/content-type-text)
(= content-type constants/content-type-emoji))
(open-chat-context-menu message))}
[react/view {:accessibility-label :chat-item}
(let [incoming-group (and group-chat (not outgoing))]
[message-content message-body (merge message

View File

@ -17,7 +17,6 @@
[status-im.ui.components.toolbar.actions :as toolbar.actions]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.screens.chat.actions :as actions]
[status-im.ui.screens.chat.bottom-info :as bottom-info]
[status-im.ui.screens.chat.input.input :as input]
[status-im.ui.screens.chat.message.datemark :as message-datemark]
[status-im.ui.screens.chat.message.gap :as gap]
@ -459,7 +458,6 @@
(letsubs [{:keys [public? chat-id show-input?] :as current-chat}
[:chats/current-chat]
current-chat-id [:chats/current-chat-id]
show-bottom-info? [:chats/current-chat-ui-prop :show-bottom-info?]
show-message-options? [:chats/current-chat-ui-prop :show-message-options?]
show-stickers? [:chats/current-chat-ui-prop :show-stickers?]]
;; this check of current-chat-id is necessary only because in a fresh public chat creation sometimes
@ -487,8 +485,6 @@
[input/container])
(when show-stickers?
[stickers/stickers-view])
(when show-bottom-info?
[bottom-info/bottom-info-view])
(when show-message-options?
[message-options/view])]])))

View File

@ -95,11 +95,11 @@
:number-of-lines 5}
(core-utils/truncate-str text constants/chars-collapse-threshold)]]))
(defn- message-sent? [user-statuses current-public-key]
(not= (get-in user-statuses [current-public-key :status]) :not-sent))
(defn- message-sent? [outgoing-status]
(not (#{:not-sent :sending} outgoing-status)))
(views/defview message-without-timestamp
[text {:keys [chat-id message-id old-message-id content group-chat expanded? current-public-key user-statuses] :as message} style]
[text {:keys [chat-id message-id old-message-id content group-chat expanded? current-public-key outgoing-status] :as message} style]
[react/view {:flex 1 :margin-vertical 5}
[react/touchable-highlight {:on-press (fn [arg]
(when (= "right" (.-button (.-nativeEvent arg)))
@ -107,7 +107,7 @@
[{:text (i18n/label :t/sharing-copy-to-clipboard)
:on-select #(do (utils/show-popup "" "Message copied to clipboard") (react/copy-to-clipboard text))}
{:text (i18n/label :t/message-reply)
:on-select #(when (message-sent? user-statuses current-public-key)
:on-select #(when (message-sent? outgoing-status)
(re-frame/dispatch [:chat.ui/reply-to-message message-id old-message-id]))}])))}
(let [collapsible? (and (:should-collapse? content) group-chat)
char-limit (if (and collapsible? (not expanded?))
@ -185,7 +185,7 @@
[message-content-status text message])
(defmethod message :default
[text me? {:keys [message-id chat-id message-status user-statuses from
[text me? {:keys [message-id chat-id message-status from
current-public-key content-type outgoing type value] :as message}]
(cond
(= type :datemark)
@ -199,17 +199,7 @@
:else
(when (contains? constants/desktop-content-types content-type)
(reagent.core/create-class
{:component-did-mount
#(when (and message-id
chat-id
(not outgoing)
(not= :seen message-status)
(not= :seen (keyword (get-in user-statuses [current-public-key :status]))))
;;TODO(rasom): revisit this when seen messages will be reimplemented
#_(re-frame/dispatch [:send-seen! {:chat-id chat-id
:from from
:message-id message-id}]))
:reagent-render
{:reagent-render
(fn []
^{:key (str "message" message-id)}
[react/view

View File

@ -115,11 +115,10 @@
(is (= #{"1" "2"}
(set (keys (db/active-chats {} chats {}))))))))
(deftest messages-with-datemarks-and-statuses
(deftest messages-with-datemarks
(testing "empty state"
(is (empty?
(db/messages-with-datemarks-and-statuses
nil
(db/messages-with-datemarks
nil
nil
nil
@ -132,8 +131,7 @@
[{:type :gap
:value ":first-gap"
:first-gap? true}]
(db/messages-with-datemarks-and-statuses
nil
(db/messages-with-datemarks
nil
nil
nil
@ -148,13 +146,11 @@
:timestamp 40
:content nil
:timestamp-str "14:00"
:user-statuses nil
:datemark "today"}
{:whisper-timestamp 30
:timestamp 30
:content nil
:timestamp-str "13:00"
:user-statuses nil
:datemark "today"}
{:value "today"
:type :datemark
@ -164,19 +160,17 @@
:timestamp 20
:content nil
:timestamp-str "12:00"
:user-statuses nil
:datemark "yesterday"}
{:whisper-timestamp 10
:timestamp 10
:content nil
:timestamp-str "11:00"
:user-statuses nil
:datemark "yesterday"}
{:value "yesterday"
:type :datemark
:whisper-timestamp 10
:timestamp 10})
(db/messages-with-datemarks-and-statuses
(db/messages-with-datemarks
{"yesterday"
(list
{:message-id :m1
@ -207,6 +201,8 @@
:timestamp 40}}
nil
nil
nil
nil
nil))))
(testing "simple case with gap"
(is (=
@ -214,7 +210,6 @@
:timestamp 40
:content nil
:timestamp-str "14:00"
:user-statuses nil
:datemark "today"}
{:type :gap
:value ":gapid1"
@ -223,7 +218,6 @@
:timestamp 30
:content nil
:timestamp-str "13:00"
:user-statuses nil
:datemark "today"}
{:value "today"
:type :datemark
@ -233,19 +227,17 @@
:timestamp 20
:content nil
:timestamp-str "12:00"
:user-statuses nil
:datemark "yesterday"}
{:whisper-timestamp 10
:timestamp 10
:content nil
:timestamp-str "11:00"
:user-statuses nil
:datemark "yesterday"}
{:value "yesterday"
:type :datemark
:whisper-timestamp 10
:timestamp 10})
(db/messages-with-datemarks-and-statuses
(db/messages-with-datemarks
{"yesterday"
(list
{:message-id :m1
@ -275,10 +267,12 @@
:m4 {:whisper-timestamp 40
:timestamp 40}}
nil
nil
[{:from 25
:to 30
:id :gapid1}]))))
:id :gapid1}]
nil
nil
nil))))
(testing "simple case with gap after all messages"
(is (=
'({:type :gap
@ -288,13 +282,11 @@
:timestamp 40
:content nil
:timestamp-str "14:00"
:user-statuses nil
:datemark "today"}
{:whisper-timestamp 30
:timestamp 30
:content nil
:timestamp-str "13:00"
:user-statuses nil
:datemark "today"}
{:value "today"
:type :datemark
@ -304,19 +296,17 @@
:timestamp 20
:content nil
:timestamp-str "12:00"
:user-statuses nil
:datemark "yesterday"}
{:whisper-timestamp 10
:timestamp 10
:content nil
:timestamp-str "11:00"
:user-statuses nil
:datemark "yesterday"}
{:value "yesterday"
:type :datemark
:whisper-timestamp 10
:timestamp 10})
(db/messages-with-datemarks-and-statuses
(db/messages-with-datemarks
{"yesterday"
(list
{:message-id :m1
@ -346,7 +336,9 @@
:m4 {:whisper-timestamp 40
:timestamp 40}}
nil
nil
[{:from 100
:to 110
:id :gapid1}])))))
:id :gapid1}]
nil
nil
nil)))))

View File

@ -175,46 +175,17 @@
{:account/account {:public-key "me"}
:chats {"status" {:public? true
:group-chat true
:loaded-unviewed-messages-ids #{"6" "5" "4"}
:message-statuses {"6" {"me" {:message-id "6"
:chat-id "status"
:public-key "me"
:status :received}}
"5" {"me" {:message-id "5"
:chat-id "status"
:public-key "me"
:status :received}}
"4" {"me" {:message-id "4"
:chat-id "status"
:public-key "me"
:status :received}}}}
"opened" {:loaded-unviewed-messages-ids #{}
:message-statuses {"1" {"me" {:message-id "1"
:chat-id "opened"
:public-key "me"
:status :seen}}}}
"1-1" {:loaded-unviewed-messages-ids #{"6" "5" "4"}
:message-statuses {"6" {"me" {:message-id "6"
:chat-id "status"
:public-key "me"
:status :received}}
"5" {"me" {:message-id "5"
:chat-id "status"
:public-key "me"
:status :received}}
"4" {"me" {:message-id "4"
:chat-id "status"
:public-key "me"
:status :received}}}}}})
:messages {"4" {} "5" {} "6" {}}
:loaded-unviewed-messages-ids #{"6" "5" "4"}}
"opened" {:loaded-unviewed-messages-ids #{}}
"1-1" {:loaded-unviewed-messages-ids #{"6" "5" "4"}}}})
(deftest mark-messages-seen
(testing "Marking messages seen correctly marks loaded messages as seen and updates absolute unviewed set"
(let [fx (chat/mark-messages-seen {:db test-db} "status")
me (get-in test-db [:account/account :public-key])]
(is (= '(:seen :seen :seen)
(map (fn [[_ v]]
(get-in v [me :status]))
(get-in fx [:db :chats "status" :message-statuses]))))
(is (= '(true true true)
(map (comp :seen second) (get-in fx [:db :chats "status" :messages]))))
(is (= 2 (count (:data-store/tx fx))))
;; for public chats, no confirmation is sent out
(is (= nil (:shh/post fx)))))

View File

@ -50,8 +50,7 @@
:chat-id "chat-id"
:content "b"
:clock-value 1}])
message (get-in actual [:db :chats "chat-id" :messages "id"])
status (get-in actual [:db :chats "chat-id" :message-statuses "id" "me" :status])]
message (get-in actual [:db :chats "chat-id" :messages "id"])]
(testing "it adds the message"
(is message))
(testing "it marks the message as outgoing"
@ -59,9 +58,7 @@
(testing "it stores the message"
(is (:data-store/tx actual)))
(testing "it does not send a seen confirmation"
(is (not (:shh/post actual))))
(testing "it marks it as sent"
(is (= :sent status)))))))
(is (not (:shh/post actual))))))))
(deftest receive-many-clock-value
(let [db {:account/account {:public-key "me"}

View File

@ -101,16 +101,15 @@
(get-in cofx [:db :transport/message-envelopes "hash-1"]))))
(testing "the message is sent"
(is (= :sent
(get-in
(message/update-envelope-status cofx "hash-1" :sent)
[:db :chats chat-id :message-statuses message-id from :status]))))
[:db :chats chat-id :messages message-id :outgoing-status]))))
(testing "the message is not sent"
(is (= :not-sent
(get-in
(message/update-envelope-status cofx "hash-1" :not-sent)
[:db :chats chat-id :message-statuses message-id from :status]))))))
[:db :chats chat-id :messages message-id :outgoing-status]))))))
(testing "multi envelope message"
(testing "only inserts"
(let [cofx (fx/merge
@ -136,7 +135,7 @@
(is (= :sent
(get-in
cofx
[:db :chats chat-id :message-statuses message-id from :status]))))))
[:db :chats chat-id :messages message-id :outgoing-status]))))))
(testing "message not sent"
(let [cofx (fx/merge
initial-cofx
@ -152,4 +151,4 @@
(is (= :not-sent
(get-in
cofx
[:db :chats chat-id :message-statuses message-id from :status])))))))))
[:db :chats chat-id :messages message-id :outgoing-status])))))))))