From c0be3bb2ba70fc9af4cc12c8e6f657452c74dac9 Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Wed, 31 Aug 2022 17:32:19 +1000 Subject: [PATCH] Move to waypoints from location --- package.json | 8 +- pnpm-lock.yaml | 173 ++++++++++-------- src/core/stores/deviceStore.ts | 38 ++-- src/core/subscriptions.ts | 18 +- src/pages/Messages/ChannelChat.tsx | 12 +- src/pages/Messages/Message.tsx | 37 ++-- src/pages/Messages/NewLocationMessage.tsx | 4 +- ...ocationMessage.tsx => WaypointMessage.tsx} | 21 ++- 8 files changed, 177 insertions(+), 134 deletions(-) rename src/pages/Messages/{LocationMessage.tsx => WaypointMessage.tsx} (60%) diff --git a/package.json b/package.json index 0bf23806..ef00d4f5 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@emeraldpay/hashicon-react": "^0.5.2", "@hookform/resolvers": "^2.9.7", "@meshtastic/eslint-config": "^1.0.8", - "@meshtastic/meshtasticjs": "^0.6.92", + "@meshtastic/meshtasticjs": "^0.6.95", "base64-js": "^1.5.1", "class-transformer": "^0.5.1", "class-validator": "^0.13.2", @@ -30,7 +30,7 @@ "geodesy": "^2.4.0", "immer": "^9.0.15", "mapbox-gl": "npm:empty-npm-package@^1.0.0", - "maplibre-gl": "^2.3.0", + "maplibre-gl": "^2.4.0", "modern-css-reset": "^1.4.0", "prettier": "^2.7.1", "react": "^18.2.0", @@ -46,8 +46,8 @@ "devDependencies": { "@types/chrome": "^0.0.195", "@types/geodesy": "^2.2.3", - "@types/node": "^18.7.13", - "@types/react": "^18.0.17", + "@types/node": "^18.7.14", + "@types/react": "^18.0.18", "@types/react-dom": "^18.0.6", "@types/w3c-web-serial": "^1.0.2", "@types/web-bluetooth": "^0.0.15", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index abe8a842..049d0939 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,11 +4,11 @@ specifiers: '@emeraldpay/hashicon-react': ^0.5.2 '@hookform/resolvers': ^2.9.7 '@meshtastic/eslint-config': ^1.0.8 - '@meshtastic/meshtasticjs': ^0.6.92 + '@meshtastic/meshtasticjs': ^0.6.95 '@types/chrome': ^0.0.195 '@types/geodesy': ^2.2.3 - '@types/node': ^18.7.13 - '@types/react': ^18.0.17 + '@types/node': ^18.7.14 + '@types/react': ^18.0.18 '@types/react-dom': ^18.0.6 '@types/w3c-web-serial': ^1.0.2 '@types/web-bluetooth': ^0.0.15 @@ -21,7 +21,7 @@ specifiers: gzipper: ^7.1.0 immer: ^9.0.15 mapbox-gl: npm:empty-npm-package@^1.0.0 - maplibre-gl: ^2.3.0 + maplibre-gl: ^2.4.0 modern-css-reset: ^1.4.0 prettier: ^2.7.1 react: ^18.2.0 @@ -44,7 +44,7 @@ dependencies: '@emeraldpay/hashicon-react': 0.5.2 '@hookform/resolvers': 2.9.7_react-hook-form@7.34.2 '@meshtastic/eslint-config': 1.0.8 - '@meshtastic/meshtasticjs': 0.6.92 + '@meshtastic/meshtasticjs': 0.6.95 base64-js: 1.5.1 class-transformer: 0.5.1 class-validator: 0.13.2 @@ -52,7 +52,7 @@ dependencies: geodesy: 2.4.0 immer: 9.0.15 mapbox-gl: /empty-npm-package/1.0.0 - maplibre-gl: 2.3.0 + maplibre-gl: 2.4.0 modern-css-reset: 1.4.0 prettier: 2.7.1 react: 18.2.0 @@ -68,8 +68,8 @@ dependencies: devDependencies: '@types/chrome': 0.0.195 '@types/geodesy': 2.2.3 - '@types/node': 18.7.13 - '@types/react': 18.0.17 + '@types/node': 18.7.14 + '@types/react': 18.0.18 '@types/react-dom': 18.0.6 '@types/w3c-web-serial': 1.0.2 '@types/web-bluetooth': 0.0.15 @@ -524,13 +524,13 @@ packages: /@meshtastic/eslint-config/1.0.8: resolution: {integrity: sha512-Jzwaf3TyYFGeFuxLRQA5Yj5Rmz097VleFQUkswXH9nvLO81JjJbHgJWbHQ6RpxC31q/2hWV03QdaH98swpYcQA==} dependencies: - '@typescript-eslint/eslint-plugin': 5.35.1_pfwtupu3r4wxmgbx6hj7gwmyuu - '@typescript-eslint/parser': 5.35.1_yqf6kl63nyoq5megxukfnom5rm + '@typescript-eslint/eslint-plugin': 5.36.1_lbwfnm54o3pmr3ypeqp3btnera + '@typescript-eslint/parser': 5.36.1_yqf6kl63nyoq5megxukfnom5rm eslint: 8.23.0 eslint-config-prettier: 8.5.0_eslint@8.23.0 eslint-import-resolver-typescript: 2.7.1_faomjyrlgqmwswvqymymzkxcqi eslint-plugin-eslint-comments: 3.2.0_eslint@8.23.0 - eslint-plugin-import: 2.26.0_sj2rot7zah2mtyugqmkmi45scy + eslint-plugin-import: 2.26.0_un7ecal3cw2ng4g3gnr5d6g7tq eslint-plugin-react: 7.31.1_eslint@8.23.0 eslint-plugin-react-hooks: 4.6.0_eslint@8.23.0 prettier: 2.7.1 @@ -541,8 +541,8 @@ packages: - supports-color dev: false - /@meshtastic/meshtasticjs/0.6.92: - resolution: {integrity: sha512-2JgFXlrFVmb9CsgzJ7+SbmHvTxBWcH706c25UFqvST8MqLOK0Stc9GGFMKlchFzRxBJv47g9iyaFL+9vJ7exVg==} + /@meshtastic/meshtasticjs/0.6.95: + resolution: {integrity: sha512-VQ1brSTm236d4LZgIU6c/aFdboWP88q3FPfEjh/thNDTDteXNQwEJn1yH2eaohoq8By8CDzXtJLGILWvJTXTrw==} dependencies: '@meshtastic/eslint-config': 1.0.8 '@protobuf-ts/runtime': 2.8.0 @@ -766,8 +766,8 @@ packages: '@types/pbf': 3.0.2 dev: false - /@types/node/18.7.13: - resolution: {integrity: sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw==} + /@types/node/18.7.14: + resolution: {integrity: sha512-6bbDaETVi8oyIARulOE9qF1/Qdi/23z6emrUh0fNJRUmjznqrixD4MpGDdgOFk5Xb0m2H6Xu42JGdvAxaJR/wA==} dev: true /@types/pbf/3.0.2: @@ -780,25 +780,25 @@ packages: /@types/react-dom/18.0.6: resolution: {integrity: sha512-/5OFZgfIPSwy+YuIBP/FgJnQnsxhZhjjrnxudMddeblOouIodEQ75X14Rr4wGSG/bknL+Omy9iWlLo1u/9GzAA==} dependencies: - '@types/react': 18.0.17 + '@types/react': 18.0.18 dev: true /@types/react-transition-group/4.4.5: resolution: {integrity: sha512-juKD/eiSM3/xZYzjuzH6ZwpP+/lejltmiS3QEzV/vmb/Q8+HfDmxu+Baga8UEMGBqV88Nbg4l2hY/K2DkyaLLA==} dependencies: - '@types/react': 18.0.17 + '@types/react': 18.0.18 dev: false - /@types/react/16.14.30: - resolution: {integrity: sha512-tG+xGtDDSuIl1l63mN0LnaROAc99knkYyN4YTheE80iPzYvSy0U8LVie+OBZkrgjVrpkQV6bMCkSphPBnVNk6g==} + /@types/react/16.14.31: + resolution: {integrity: sha512-CD3LuBW4xIeGy6BxuNZdXBOsuP00OHFuNOq/4e2xKDq6z02XvdH9wIkuPNmz7BRQpo5ncy1zT9fz4tTDqXbjzQ==} dependencies: '@types/prop-types': 15.7.5 '@types/scheduler': 0.16.2 csstype: 3.1.0 dev: false - /@types/react/18.0.17: - resolution: {integrity: sha512-38ETy4tL+rn4uQQi7mB81G7V1g0u2ryquNmsVIOKUAEIDK+3CUjZ6rSRpdvS99dNBnkLFL83qfmtLacGOTIhwQ==} + /@types/react/18.0.18: + resolution: {integrity: sha512-6hI08umYs6NaiHFEEGioXnxJ+oEhY3eRz8VCUaudZmGdtvPviCJB8mgaMxaDWAdPSYd4eFavrPk2QIolwbLYrg==} dependencies: '@types/prop-types': 15.7.5 '@types/scheduler': 0.16.2 @@ -815,8 +815,8 @@ packages: resolution: {integrity: sha512-w7hEHXnPMEZ+4nGKl/KDRVpxkwYxYExuHOYXyzIzCDzEZ9ZCGMAewulr9IqJu2LR4N37fcnb1XVeuZ09qgOxhA==} dev: true - /@typescript-eslint/eslint-plugin/5.35.1_pfwtupu3r4wxmgbx6hj7gwmyuu: - resolution: {integrity: sha512-RBZZXZlI4XCY4Wzgy64vB+0slT9+yAPQRjj/HSaRwUot33xbDjF1oN9BLwOLTewoOI0jothIltZRe9uJCHf8gg==} + /@typescript-eslint/eslint-plugin/5.36.1_lbwfnm54o3pmr3ypeqp3btnera: + resolution: {integrity: sha512-iC40UK8q1tMepSDwiLbTbMXKDxzNy+4TfPWgIL661Ym0sD42vRcQU93IsZIrmi+x292DBr60UI/gSwfdVYexCA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: '@typescript-eslint/parser': ^5.0.0 @@ -826,10 +826,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.35.1_yqf6kl63nyoq5megxukfnom5rm - '@typescript-eslint/scope-manager': 5.35.1 - '@typescript-eslint/type-utils': 5.35.1_yqf6kl63nyoq5megxukfnom5rm - '@typescript-eslint/utils': 5.35.1_yqf6kl63nyoq5megxukfnom5rm + '@typescript-eslint/parser': 5.36.1_yqf6kl63nyoq5megxukfnom5rm + '@typescript-eslint/scope-manager': 5.36.1 + '@typescript-eslint/type-utils': 5.36.1_yqf6kl63nyoq5megxukfnom5rm + '@typescript-eslint/utils': 5.36.1_yqf6kl63nyoq5megxukfnom5rm debug: 4.3.4 eslint: 8.23.0 functional-red-black-tree: 1.0.1 @@ -842,8 +842,8 @@ packages: - supports-color dev: false - /@typescript-eslint/parser/5.35.1_yqf6kl63nyoq5megxukfnom5rm: - resolution: {integrity: sha512-XL2TBTSrh3yWAsMYpKseBYTVpvudNf69rPOWXWVBI08My2JVT5jR66eTt4IgQFHA/giiKJW5dUD4x/ZviCKyGg==} + /@typescript-eslint/parser/5.36.1_yqf6kl63nyoq5megxukfnom5rm: + resolution: {integrity: sha512-/IsgNGOkBi7CuDfUbwt1eOqUXF9WGVBW9dwEe1pi+L32XrTsZIgmDFIi2RxjzsvB/8i+MIf5JIoTEH8LOZ368A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -852,9 +852,9 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.35.1 - '@typescript-eslint/types': 5.35.1 - '@typescript-eslint/typescript-estree': 5.35.1_typescript@4.8.2 + '@typescript-eslint/scope-manager': 5.36.1 + '@typescript-eslint/types': 5.36.1 + '@typescript-eslint/typescript-estree': 5.36.1_typescript@4.8.2 debug: 4.3.4 eslint: 8.23.0 typescript: 4.8.2 @@ -862,16 +862,16 @@ packages: - supports-color dev: false - /@typescript-eslint/scope-manager/5.35.1: - resolution: {integrity: sha512-kCYRSAzIW9ByEIzmzGHE50NGAvAP3wFTaZevgWva7GpquDyFPFcmvVkFJGWJJktg/hLwmys/FZwqM9EKr2u24Q==} + /@typescript-eslint/scope-manager/5.36.1: + resolution: {integrity: sha512-pGC2SH3/tXdu9IH3ItoqciD3f3RRGCh7hb9zPdN2Drsr341zgd6VbhP5OHQO/reUqihNltfPpMpTNihFMarP2w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.35.1 - '@typescript-eslint/visitor-keys': 5.35.1 + '@typescript-eslint/types': 5.36.1 + '@typescript-eslint/visitor-keys': 5.36.1 dev: false - /@typescript-eslint/type-utils/5.35.1_yqf6kl63nyoq5megxukfnom5rm: - resolution: {integrity: sha512-8xT8ljvo43Mp7BiTn1vxLXkjpw8wS4oAc00hMSB4L1/jIiYbjjnc3Qp2GAUOG/v8zsNCd1qwcqfCQ0BuishHkw==} + /@typescript-eslint/type-utils/5.36.1_yqf6kl63nyoq5megxukfnom5rm: + resolution: {integrity: sha512-xfZhfmoQT6m3lmlqDvDzv9TiCYdw22cdj06xY0obSznBsT///GK5IEZQdGliXpAOaRL34o8phEvXzEo/VJx13Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '*' @@ -880,7 +880,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/utils': 5.35.1_yqf6kl63nyoq5megxukfnom5rm + '@typescript-eslint/typescript-estree': 5.36.1_typescript@4.8.2 + '@typescript-eslint/utils': 5.36.1_yqf6kl63nyoq5megxukfnom5rm debug: 4.3.4 eslint: 8.23.0 tsutils: 3.21.0_typescript@4.8.2 @@ -889,13 +890,13 @@ packages: - supports-color dev: false - /@typescript-eslint/types/5.35.1: - resolution: {integrity: sha512-FDaujtsH07VHzG0gQ6NDkVVhi1+rhq0qEvzHdJAQjysN+LHDCKDKCBRlZFFE0ec0jKxiv0hN63SNfExy0KrbQQ==} + /@typescript-eslint/types/5.36.1: + resolution: {integrity: sha512-jd93ShpsIk1KgBTx9E+hCSEuLCUFwi9V/urhjOWnOaksGZFbTOxAT47OH2d4NLJnLhkVD+wDbB48BuaycZPLBg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: false - /@typescript-eslint/typescript-estree/5.35.1_typescript@4.8.2: - resolution: {integrity: sha512-JUqE1+VRTGyoXlDWWjm6MdfpBYVq+hixytrv1oyjYIBEOZhBCwtpp5ZSvBt4wIA1MKWlnaC2UXl2XmYGC3BoQA==} + /@typescript-eslint/typescript-estree/5.36.1_typescript@4.8.2: + resolution: {integrity: sha512-ih7V52zvHdiX6WcPjsOdmADhYMDN15SylWRZrT2OMy80wzKbc79n8wFW0xpWpU0x3VpBz/oDgTm2xwDAnFTl+g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -903,8 +904,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.35.1 - '@typescript-eslint/visitor-keys': 5.35.1 + '@typescript-eslint/types': 5.36.1 + '@typescript-eslint/visitor-keys': 5.36.1 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 @@ -915,16 +916,16 @@ packages: - supports-color dev: false - /@typescript-eslint/utils/5.35.1_yqf6kl63nyoq5megxukfnom5rm: - resolution: {integrity: sha512-v6F8JNXgeBWI4pzZn36hT2HXXzoBBBJuOYvoQiaQaEEjdi5STzux3Yj8v7ODIpx36i/5s8TdzuQ54TPc5AITQQ==} + /@typescript-eslint/utils/5.36.1_yqf6kl63nyoq5megxukfnom5rm: + resolution: {integrity: sha512-lNj4FtTiXm5c+u0pUehozaUWhh7UYKnwryku0nxJlYUEWetyG92uw2pr+2Iy4M/u0ONMKzfrx7AsGBTCzORmIg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: '@types/json-schema': 7.0.11 - '@typescript-eslint/scope-manager': 5.35.1 - '@typescript-eslint/types': 5.35.1 - '@typescript-eslint/typescript-estree': 5.35.1_typescript@4.8.2 + '@typescript-eslint/scope-manager': 5.36.1 + '@typescript-eslint/types': 5.36.1 + '@typescript-eslint/typescript-estree': 5.36.1_typescript@4.8.2 eslint: 8.23.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0_eslint@8.23.0 @@ -933,11 +934,11 @@ packages: - typescript dev: false - /@typescript-eslint/visitor-keys/5.35.1: - resolution: {integrity: sha512-cEB1DvBVo1bxbW/S5axbGPE6b7FIMAbo3w+AGq6zNDA7+NYJOIkKj/sInfTv4edxd4PxJSgdN4t6/pbvgA+n5g==} + /@typescript-eslint/visitor-keys/5.36.1: + resolution: {integrity: sha512-ojB9aRyRFzVMN3b5joSYni6FAS10BBSCAfKJhjJAV08t/a95aM6tAhz+O1jF+EtgxktuSO3wJysp2R+Def/IWQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.35.1 + '@typescript-eslint/types': 5.36.1 eslint-visitor-keys: 3.3.0 dev: false @@ -952,7 +953,7 @@ packages: '@babel/plugin-transform-react-jsx-development': 7.18.6_@babel+core@7.18.13 '@babel/plugin-transform-react-jsx-self': 7.18.6_@babel+core@7.18.13 '@babel/plugin-transform-react-jsx-source': 7.18.6_@babel+core@7.18.13 - magic-string: 0.26.2 + magic-string: 0.26.3 react-refresh: 0.14.0 vite: 3.0.9 transitivePeerDependencies: @@ -1083,8 +1084,8 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001383 - electron-to-chromium: 1.4.233 + caniuse-lite: 1.0.30001385 + electron-to-chromium: 1.4.237 node-releases: 2.0.6 update-browserslist-db: 1.0.5_browserslist@4.21.3 dev: true @@ -1104,8 +1105,8 @@ packages: engines: {node: '>=6'} dev: false - /caniuse-lite/1.0.30001383: - resolution: {integrity: sha512-swMpEoTp5vDoGBZsYZX7L7nXHe6dsHxi9o6/LKf/f0LukVtnrxly5GVb/fWdCDTqi/yw6Km6tiJ0pmBacm0gbg==} + /caniuse-lite/1.0.30001385: + resolution: {integrity: sha512-MpiCqJGhBkHgpyimE9GWmZTnyHyEEM35u115bD3QBrXpjvL/JgcP8cUhKJshfmg4OtEHFenifcK5sZayEw5tvQ==} dev: true /chalk/2.4.2: @@ -1182,7 +1183,7 @@ packages: dev: false /concat-map/0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} dev: false /convert-source-map/1.8.0: @@ -1349,8 +1350,8 @@ packages: resolution: {integrity: sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ==} dev: false - /electron-to-chromium/1.4.233: - resolution: {integrity: sha512-ejwIKXTg1wqbmkcRJh9Ur3hFGHFDZDw1POzdsVrB2WZjgRuRMHIQQKNpe64N/qh3ZtH2otEoRoS+s6arAAuAAw==} + /electron-to-chromium/1.4.237: + resolution: {integrity: sha512-vxVyGJcsgArNOVUJcXm+7iY3PJAfmSapEszQD1HbyPLl0qoCmNQ1o/EX3RI7Et5/88In9oLxX3SGF8J3orkUgA==} dev: true /emoji-regex/8.0.0: @@ -1678,7 +1679,7 @@ packages: dependencies: debug: 4.3.4 eslint: 8.23.0 - eslint-plugin-import: 2.26.0_sj2rot7zah2mtyugqmkmi45scy + eslint-plugin-import: 2.26.0_un7ecal3cw2ng4g3gnr5d6g7tq glob: 7.2.3 is-glob: 4.0.3 resolve: 1.22.1 @@ -1687,7 +1688,7 @@ packages: - supports-color dev: false - /eslint-module-utils/2.7.4_s6e6arjyixr5636axeptmcw4pu: + /eslint-module-utils/2.7.4_w7bm4lrjugp7jlqhliwaf5i2ta: resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==} engines: {node: '>=4'} peerDependencies: @@ -1708,7 +1709,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.35.1_yqf6kl63nyoq5megxukfnom5rm + '@typescript-eslint/parser': 5.36.1_yqf6kl63nyoq5megxukfnom5rm debug: 3.2.7 eslint: 8.23.0 eslint-import-resolver-node: 0.3.6 @@ -1728,7 +1729,7 @@ packages: ignore: 5.2.0 dev: false - /eslint-plugin-import/2.26.0_sj2rot7zah2mtyugqmkmi45scy: + /eslint-plugin-import/2.26.0_un7ecal3cw2ng4g3gnr5d6g7tq: resolution: {integrity: sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==} engines: {node: '>=4'} peerDependencies: @@ -1738,14 +1739,14 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.35.1_yqf6kl63nyoq5megxukfnom5rm + '@typescript-eslint/parser': 5.36.1_yqf6kl63nyoq5megxukfnom5rm array-includes: 3.1.5 array.prototype.flat: 1.3.0 debug: 2.6.9 doctrine: 2.1.0 eslint: 8.23.0 eslint-import-resolver-node: 0.3.6 - eslint-module-utils: 2.7.4_s6e6arjyixr5636axeptmcw4pu + eslint-module-utils: 2.7.4_w7bm4lrjugp7jlqhliwaf5i2ta has: 1.0.3 is-core-module: 2.10.0 is-glob: 4.0.3 @@ -1923,7 +1924,7 @@ packages: dependencies: '@babel/runtime': 7.18.9 '@segment/react-tiny-virtual-list': 2.2.1_react@18.2.0 - '@types/react': 16.14.30 + '@types/react': 16.14.31 '@types/react-transition-group': 4.4.5 arrify: 1.0.1 classnames: 2.3.1 @@ -2146,6 +2147,15 @@ packages: path-is-absolute: 1.0.1 dev: false + /global-prefix/3.0.0: + resolution: {integrity: sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==} + engines: {node: '>=6'} + dependencies: + ini: 1.3.8 + kind-of: 6.0.3 + which: 1.3.1 + dev: false + /globals/11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} engines: {node: '>=4'} @@ -2272,6 +2282,10 @@ packages: /inherits/2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + /ini/1.3.8: + resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} + dev: false + /inline-style-prefixer/3.0.8: resolution: {integrity: sha512-ne8XIyyqkRaNJ1JfL1NYzNdCNxq+MCBQhC8NgOQlzNm2vv3XxlP0VSLQUbSRCF6KPEoveCVEpayHoHzcMyZsMQ==} dependencies: @@ -2518,6 +2532,11 @@ packages: resolution: {integrity: sha512-hRkd6/XW4HTsA9vjVpY9tuXJYLSlelnkTmVFu4M9/7MIYQtFcHpbugAU7UbOfjOiVSVYl2fqgBuJ32JUmRo5Ew==} dev: false + /kind-of/6.0.3: + resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} + engines: {node: '>=0.10.0'} + dev: false + /levn/0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} @@ -2579,15 +2598,15 @@ packages: yallist: 4.0.0 dev: false - /magic-string/0.26.2: - resolution: {integrity: sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==} + /magic-string/0.26.3: + resolution: {integrity: sha512-u1Po0NDyFcwdg2nzHT88wSK0+Rih0N1M+Ph1Sp08k8yvFFU3KR72wryS7e1qMPJypt99WB7fIFVCA92mQrMjrg==} engines: {node: '>=12'} dependencies: sourcemap-codec: 1.4.8 dev: true - /maplibre-gl/2.3.0: - resolution: {integrity: sha512-91vc5Quu9UDw0S90pJMDuE24XvXUjIYGaD5DTlhNs3egVmX0QwCpWl1R2tots3slHbZRJcQdRGUNxW7hKpi0Ow==} + /maplibre-gl/2.4.0: + resolution: {integrity: sha512-csNFylzntPmHWidczfgCZpvbTSmhaWvLRj9e1ezUDBEPizGgshgm3ea1T5TCNEEBq0roauu7BPuRZjA3wO4KqA==} requiresBuild: true dependencies: '@mapbox/geojson-rewind': 0.5.2 @@ -2606,6 +2625,7 @@ packages: earcut: 2.2.4 geojson-vt: 3.2.1 gl-matrix: 3.4.3 + global-prefix: 3.0.0 murmurhash-js: 1.0.0 pbf: 3.2.1 potpack: 1.0.2 @@ -2952,7 +2972,7 @@ packages: dev: false /quotemeta/0.0.0: - resolution: {integrity: sha512-1XGObUh7RN5b58vKuAsrlfqT+Rc4vmw8N4pP9gFCq1GFlTdV0Ex/D2Ro1Drvrqj++HPi3ig0Np17XPslELeMRA==} + resolution: {integrity: sha1-UdOgbuD81uO1AdvSiQQ1Gtelo4w=} dev: true /react-dom/18.2.0_react@18.2.0: @@ -3623,6 +3643,13 @@ packages: is-typed-array: 1.1.9 dev: true + /which/1.3.1: + resolution: {integrity: sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==} + hasBin: true + dependencies: + isexe: 2.0.0 + dev: false + /which/2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} diff --git a/src/core/stores/deviceStore.ts b/src/core/stores/deviceStore.ts index a043aeed..d28af778 100644 --- a/src/core/stores/deviceStore.ts +++ b/src/core/stores/deviceStore.ts @@ -13,16 +13,21 @@ export type Page = | "channels" | "info"; -export interface MessageWithAck { - message: Types.MessagePacket; +export interface MessageWithAck extends Types.MessagePacket { ack: boolean; - received: Date; } +export interface WaypointIDWithAck extends Omit { + waypointID: number; + ack: boolean; +} + +export type AllMessageTypes = MessageWithAck | WaypointIDWithAck; + export interface Channel { config: Protobuf.Channel; lastInterraction: Date; - messages: MessageWithAck[]; + messages: AllMessageTypes[]; } export interface Node { @@ -44,7 +49,7 @@ export interface Device { activePage: Page; peerInfoOpen: boolean; activePeer: number; - waypoints: Protobuf.Location[]; + waypoints: Protobuf.Waypoint[]; regionUnset: boolean; setReady(ready: boolean): void; @@ -57,12 +62,13 @@ export interface Device { setPeerInfoOpen: (open: boolean) => void; setActivePeer: (peer: number) => void; addChannel: (channel: Channel) => void; - addWaypoint: (waypoint: Protobuf.Location) => void; + addWaypoint: (waypoint: Protobuf.Waypoint) => void; addNodeInfo: (nodeInfo: Types.NodeInfoPacket) => void; addUser: (user: Types.UserPacket) => void; addPosition: (position: Types.PositionPacket) => void; addConnection: (connection: IConnection) => void; addMessage: (message: MessageWithAck) => void; + addWaypointMessage: (message: WaypointIDWithAck) => void; ackMessage: (channelIndex: number, messageId: number) => void; } @@ -265,7 +271,7 @@ export const useDeviceStore = create((set, get) => ({ }) ); }, - addWaypoint: (waypoint: Protobuf.Location) => { + addWaypoint: (waypoint: Protobuf.Waypoint) => { set( produce((draft) => { const device = draft.devices.get(id); @@ -404,14 +410,24 @@ export const useDeviceStore = create((set, get) => ({ const device = draft.devices.get(id); if (device) { device.channels - .find( - (ch) => ch.config.index === message.message.packet.channel - ) + .find((ch) => ch.config.index === message.packet.channel) ?.messages.push(message); } }) ); }, + addWaypointMessage: (waypointID) => { + set( + produce((draft) => { + const device = draft.devices.get(id); + if (device) { + device.channels + .find((ch) => ch.config.index === waypointID.packet.channel) + ?.messages.push(waypointID); + } + }) + ); + }, ackMessage: (channelIndex: number, messageId: number) => { console.log("ack called"); @@ -424,7 +440,7 @@ export const useDeviceStore = create((set, get) => ({ ); if (channel) { const message = channel.messages.find( - (msg) => msg.message.packet.id === messageId + (msg) => msg.packet.id === messageId ); if (message) { message.ack = true; diff --git a/src/core/subscriptions.ts b/src/core/subscriptions.ts index f26252b6..28aa425f 100644 --- a/src/core/subscriptions.ts +++ b/src/core/subscriptions.ts @@ -32,6 +32,16 @@ export const subscribeAll = (device: Device, connection: IConnection) => { } }); + connection.onWaypointPacket.subscribe((waypoint) => { + const { data, ...rest } = waypoint; + device.addWaypoint(data); + device.addWaypointMessage({ + waypointID: data.id, + ack: rest.packet.from !== device.hardware.myNodeNum, + ...rest, + }); + }); + connection.onMyNodeInfo.subscribe((nodeInfo) => { device.setHardware(nodeInfo); }); @@ -64,14 +74,8 @@ export const subscribeAll = (device: Device, connection: IConnection) => { connection.onMessagePacket.subscribe((messagePacket) => { device.addMessage({ - message: messagePacket, + ...messagePacket, ack: messagePacket.packet.from !== device.hardware.myNodeNum, - received: messagePacket.packet.rxTime - ? new Date(messagePacket.packet.rxTime * 1000) - : new Date(), }); - if (messagePacket.location) { - device.addWaypoint(messagePacket.location); - } }); }; diff --git a/src/pages/Messages/ChannelChat.tsx b/src/pages/Messages/ChannelChat.tsx index 450abd68..ab2a0aae 100644 --- a/src/pages/Messages/ChannelChat.tsx +++ b/src/pages/Messages/ChannelChat.tsx @@ -45,19 +45,15 @@ export const ChannelChat = ({ channel }: ChannelChatProps): JSX.Element => { {channel.messages.map((message, index) => ( node.data.num === message.message.packet.from - )?.data + nodes.find((node) => node.data.num === message.packet.from)?.data } /> ))} diff --git a/src/pages/Messages/Message.tsx b/src/pages/Messages/Message.tsx index fd2de6fe..787d3356 100644 --- a/src/pages/Messages/Message.tsx +++ b/src/pages/Messages/Message.tsx @@ -10,50 +10,47 @@ import { Text, } from "evergreen-ui"; +import type { AllMessageTypes } from "@app/core/stores/deviceStore.js"; +import { WaypointMessage } from "@app/pages/Messages/WaypointMessage.js"; import { useDevice } from "@core/providers/useDevice.js"; import { Hashicon } from "@emeraldpay/hashicon-react"; -import type { Protobuf, Types } from "@meshtastic/meshtasticjs"; -import { LocationMessage } from "@pages/Messages/LocationMessage.js"; +import type { Protobuf } from "@meshtastic/meshtasticjs"; export interface MessageProps { lastMsgSameUser: boolean; - messagePacket: Types.MessagePacket; - ack: boolean; - rxTime: Date; + message: AllMessageTypes; sender?: Protobuf.NodeInfo; } export const Message = ({ lastMsgSameUser, - messagePacket, - ack, - rxTime, + message, sender, }: MessageProps): JSX.Element => { const { setPeerInfoOpen, setActivePeer } = useDevice(); const openPeer = (): void => { - setActivePeer(messagePacket.packet.from); + setActivePeer(message.packet.from); setPeerInfoOpen(true); }; return lastMsgSameUser ? ( - {ack ? ( + {message.ack ? ( ) : ( )} - {messagePacket.location ? ( - + {"waypointID" in message ? ( + ) : ( - {messagePacket.text} + {message.text} )} @@ -67,28 +64,28 @@ export const Message = ({ {sender?.user?.longName ?? "UNK"} - {rxTime.toLocaleTimeString(undefined, { + {new Date(message.packet.rxTime).toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", })} - {ack ? ( + {message.ack ? ( ) : ( )} - {messagePacket.location ? ( - + {"waypointID" in message ? ( + ) : ( - {messagePacket.text} + {message.text} )} diff --git a/src/pages/Messages/NewLocationMessage.tsx b/src/pages/Messages/NewLocationMessage.tsx index caa8e698..56096b84 100644 --- a/src/pages/Messages/NewLocationMessage.tsx +++ b/src/pages/Messages/NewLocationMessage.tsx @@ -37,8 +37,8 @@ export const NewLocationMessage = (): JSX.Element => {