Fix message ack's

This commit is contained in:
Sacha Weatherstone
2022-10-08 18:47:15 +10:30
parent beba475864
commit 0e585d9258
3 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
import { fromByteArray, toByteArray } from "base64-js"; import { fromByteArray, toByteArray } from "base64-js";
import { Controller, useForm } from "react-hook-form"; import { Controller, useForm } from "react-hook-form";
import toast from "react-hot-toast"; import { toast } from "react-hot-toast";
import { Input } from "@app/components/form/Input.js"; import { Input } from "@app/components/form/Input.js";
import { Form } from "@components/form/Form"; import { Form } from "@components/form/Form";
@@ -31,7 +31,7 @@ export const Message = ({
return lastMsgSameUser ? ( return lastMsgSameUser ? (
<div className="ml-4 flex"> <div className="ml-4 flex">
{message.ack ? ( {message.ack ? (
<CheckCircleIcon className="my-auto h-4 text-slate-200" /> <CheckCircleIcon className="my-auto h-4 text-slate-400" />
) : ( ) : (
<EllipsisHorizontalCircleIcon className="my-auto h-4 text-slate-200" /> <EllipsisHorizontalCircleIcon className="my-auto h-4 text-slate-200" />
)} )}
@@ -68,7 +68,7 @@ export const Message = ({
</div> </div>
<div className="flex"> <div className="flex">
{message.ack ? ( {message.ack ? (
<CheckCircleIcon className="my-auto h-4 text-slate-200" /> <CheckCircleIcon className="my-auto h-4 text-slate-400" />
) : ( ) : (
<EllipsisHorizontalCircleIcon className="my-auto h-4 text-slate-200" /> <EllipsisHorizontalCircleIcon className="my-auto h-4 text-slate-200" />
)} )}
+5 -3
View File
@@ -1,4 +1,4 @@
import toast from "react-hot-toast"; import { toast } from "react-hot-toast";
import type { Device } from "@core/stores/deviceStore.js"; import type { Device } from "@core/stores/deviceStore.js";
import { Protobuf, Types } from "@meshtastic/meshtasticjs"; import { Protobuf, Types } from "@meshtastic/meshtasticjs";
@@ -7,6 +7,7 @@ export const subscribeAll = (
device: Device, device: Device,
connection: Types.ConnectionType connection: Types.ConnectionType
) => { ) => {
let myNodeNum = 0;
connection.setLogLevel(Protobuf.LogRecord_Level.TRACE); connection.setLogLevel(Protobuf.LogRecord_Level.TRACE);
// onLogEvent // onLogEvent
@@ -37,13 +38,14 @@ export const subscribeAll = (
device.addWaypoint(data); device.addWaypoint(data);
device.addWaypointMessage({ device.addWaypointMessage({
waypointID: data.id, waypointID: data.id,
ack: rest.packet.from !== device.hardware.myNodeNum, ack: rest.packet.from !== myNodeNum,
...rest, ...rest,
}); });
}); });
connection.onMyNodeInfo.subscribe((nodeInfo) => { connection.onMyNodeInfo.subscribe((nodeInfo) => {
device.setHardware(nodeInfo); device.setHardware(nodeInfo);
myNodeNum = nodeInfo.myNodeNum;
}); });
connection.onUserPacket.subscribe((user) => { connection.onUserPacket.subscribe((user) => {
@@ -78,7 +80,7 @@ export const subscribeAll = (
connection.onMessagePacket.subscribe((messagePacket) => { connection.onMessagePacket.subscribe((messagePacket) => {
device.addMessage({ device.addMessage({
...messagePacket, ...messagePacket,
ack: messagePacket.packet.from !== device.hardware.myNodeNum, ack: messagePacket.packet.from !== myNodeNum,
}); });
}); });
}; };