Add dynamic channel name with icon
This commit is contained in:
+15
-2
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { MapIcon, UsersIcon } from '@heroicons/react/outline';
|
import { HashtagIcon, MapIcon, UsersIcon } from '@heroicons/react/outline';
|
||||||
|
import { Protobuf } from '@meshtastic/meshtasticjs';
|
||||||
|
|
||||||
import { Message } from '../components/chat/Message';
|
import { Message } from '../components/chat/Message';
|
||||||
import { MessageBar } from '../components/chat/MessageBar';
|
import { MessageBar } from '../components/chat/MessageBar';
|
||||||
@@ -10,11 +11,23 @@ import { useAppSelector } from '../hooks/redux';
|
|||||||
export const Messages = (): JSX.Element => {
|
export const Messages = (): JSX.Element => {
|
||||||
const messages = useAppSelector((state) => state.meshtastic.messages);
|
const messages = useAppSelector((state) => state.meshtastic.messages);
|
||||||
const nodes = useAppSelector((state) => state.meshtastic.nodes);
|
const nodes = useAppSelector((state) => state.meshtastic.nodes);
|
||||||
|
const channels = useAppSelector((state) => state.meshtastic.channels);
|
||||||
|
|
||||||
|
const channelName = () => {
|
||||||
|
const name =
|
||||||
|
channels.find((channel) => channel.role === Protobuf.Channel_Role.PRIMARY)
|
||||||
|
?.settings?.name ?? 'Unknown';
|
||||||
|
|
||||||
|
return name.length ? name : 'Default';
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col w-full">
|
<div className="flex flex-col w-full">
|
||||||
<div className="flex justify-between w-full border-b dark:border-gray-600 dark:text-gray-300 px-2">
|
<div className="flex justify-between w-full border-b dark:border-gray-600 dark:text-gray-300 px-2">
|
||||||
<div className="my-auto text-sm"># default</div>
|
<div className="flex my-auto text-sm">
|
||||||
|
<HashtagIcon className="h-4 w-4 my-auto" />
|
||||||
|
{channelName()}
|
||||||
|
</div>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<Button>
|
<Button>
|
||||||
<MapIcon className="w-6 h-6" />
|
<MapIcon className="w-6 h-6" />
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export const Settings = (): JSX.Element => {
|
|||||||
name={t('strings.wifi_psk')}
|
name={t('strings.wifi_psk')}
|
||||||
value={radioConfig.wifiPassword}
|
value={radioConfig.wifiPassword}
|
||||||
onChange={(event) => {}}
|
onChange={(event) => {}}
|
||||||
type="text"
|
type="password"
|
||||||
valid={true}
|
valid={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user