Browse Source

fix: restore aliased paths to vite config

pull/487/head
Dan Ditomaso 1 year ago
parent
commit
d54a612e0b
  1. 16
      src/core/subscriptions.ts
  2. 5
      src/pages/Messages.tsx
  3. 18
      src/pages/Nodes.tsx
  4. 11
      vite.config.ts

16
src/core/subscriptions.ts

@ -1,9 +1,9 @@
import type { Device } from "@core/stores/deviceStore.ts";
import { Protobuf, type Types } from "@meshtastic/core";
import { MeshDevice, Protobuf } from "@meshtastic/core";
export const subscribeAll = (
device: Device,
connection: Types.ConnectionType,
connection: MeshDevice,
) => {
let myNodeNum = 0;
@ -70,6 +70,8 @@ export const subscribeAll = (
});
connection.events.onChannelPacket.subscribe((channel) => {
console.log('channel', channel);
device.addChannel(channel);
});
connection.events.onConfigPacket.subscribe((config) => {
@ -80,6 +82,9 @@ export const subscribeAll = (
});
connection.events.onMessagePacket.subscribe((messagePacket) => {
console.log('messagePacket', messagePacket);
device.addMessage({
...messagePacket,
state: messagePacket.from !== myNodeNum ? "ack" : "waiting",
@ -103,4 +108,11 @@ export const subscribeAll = (
time: meshPacket.rxTime,
});
});
connection.events.onQueueStatus.subscribe((queueStatus) => {
device.setQueueStatus(queueStatus);
if (queueStatus.free < 10) {
// start queueing messages
}
});
};

5
src/pages/Messages.tsx

@ -127,9 +127,7 @@ export const MessagesPage = () => {
<div className="flex-1 overflow-y-auto">
<ChannelChat
key={currentChannel.index}
to="broadcast"
messages={messages.broadcast.get(currentChannel.index)}
channel={currentChannel.index}
/>
</div>
</div>
@ -140,7 +138,8 @@ export const MessagesPage = () => {
<div className="flex-1 overflow-y-auto">
<ChannelChat
key={node.num}
messages={messages.direct.get(node.num)} channel={ChannelNumber.Primary} to={0} />
messages={messages.direct.get(node.num)}
/>
</div>
</div>
)}

18
src/pages/Nodes.tsx

@ -11,7 +11,7 @@ import { useDevice } from "@core/stores/deviceStore.ts";
import { Protobuf, type Types } from "@meshtastic/core";
import { numberToHexUnpadded } from "@noble/curves/abstract/utils";
import { LockIcon, LockOpenIcon } from "lucide-react";
import { Fragment, type JSX, useCallback, useEffect, useState } from "react";
import { type JSX, useCallback, useEffect, useState } from "react";
import { base16 } from "rfc4648";
export interface DeleteNoteDialogProps {
@ -21,6 +21,8 @@ export interface DeleteNoteDialogProps {
const NodesPage = (): JSX.Element => {
const { nodes, hardware, connection } = useDevice();
console.log(connection);
const [selectedNode, setSelectedNode] = useState<
Protobuf.Mesh.NodeInfo | undefined
>(undefined);
@ -61,6 +63,7 @@ const NodesPage = (): JSX.Element => {
};
}, [connection]);
const handleLocation = useCallback(
(location: Types.PacketMetadata<Protobuf.Mesh.Position>) => {
if (location.to.valueOf() !== hardware.myNodeNum) return;
@ -108,8 +111,8 @@ const NodesPage = (): JSX.Element => {
{node.user?.shortName ??
(node.user?.macaddr
? `${base16
.stringify(node.user?.macaddr.subarray(4, 6) ?? [])
.toLowerCase()}`
.stringify(node.user?.macaddr.subarray(4, 6) ?? [])
.toLowerCase()}`
: `${numberToHexUnpadded(node.num).slice(-4)}`)}
</h1>,
@ -121,8 +124,8 @@ const NodesPage = (): JSX.Element => {
{node.user?.longName ??
(node.user?.macaddr
? `Meshtastic ${base16
.stringify(node.user?.macaddr.subarray(4, 6) ?? [])
.toLowerCase()}`
.stringify(node.user?.macaddr.subarray(4, 6) ?? [])
.toLowerCase()}`
: `!${numberToHexUnpadded(node.num)}`)}
</h1>,
@ -158,9 +161,8 @@ const NodesPage = (): JSX.Element => {
{node.lastHeard !== 0
? node.viaMqtt === false && node.hopsAway === 0
? "Direct"
: `${node.hopsAway?.toString()} ${
node.hopsAway > 1 ? "hops" : "hop"
} away`
: `${node.hopsAway?.toString()} ${node.hopsAway > 1 ? "hops" : "hop"
} away`
: "-"}
{node.viaMqtt === true ? ", via MQTT" : ""}
</Mono>,

11
vite.config.ts

@ -2,6 +2,7 @@ import { defineConfig } from "vite";
import react from '@vitejs/plugin-react';
import { VitePWA } from 'vite-plugin-pwa';
import { execSync } from 'node:child_process';
import path from "node:path";
let hash = '';
try {
@ -29,6 +30,16 @@ export default defineConfig({
define: {
'import.meta.env.VITE_COMMIT_HASH': JSON.stringify(hash),
},
resolve: {
alias: {
// Using Node's path and process.cwd() instead of Deno.cwd()
'@app': path.resolve(process.cwd(), './src'),
'@pages': path.resolve(process.cwd(), './src/pages'),
'@components': path.resolve(process.cwd(), './src/components'),
'@core': path.resolve(process.cwd(), './src/core'),
'@layouts': path.resolve(process.cwd(), './src/layouts'),
},
},
server: {
port: 3000
},

Loading…
Cancel
Save