mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-07-04 17:01:45 +02:00
Add experimental double send
This commit is contained in:
@@ -92,6 +92,7 @@ export function SettingsModal({
|
||||
const [cr, setCr] = useState('');
|
||||
const [privateKey, setPrivateKey] = useState('');
|
||||
const [maxRadioContacts, setMaxRadioContacts] = useState('');
|
||||
const [experimentalChannelDoubleSend, setExperimentalChannelDoubleSend] = useState(false);
|
||||
|
||||
// Loading states
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -161,6 +162,7 @@ export function SettingsModal({
|
||||
useEffect(() => {
|
||||
if (appSettings) {
|
||||
setMaxRadioContacts(String(appSettings.max_radio_contacts));
|
||||
setExperimentalChannelDoubleSend(appSettings.experimental_channel_double_send);
|
||||
setAutoDecryptOnAdvert(appSettings.auto_decrypt_dm_on_advert);
|
||||
setAdvertInterval(String(appSettings.advert_interval));
|
||||
setBots(appSettings.bots || []);
|
||||
@@ -290,9 +292,16 @@ export function SettingsModal({
|
||||
setLoading(true);
|
||||
|
||||
try {
|
||||
const update: AppSettingsUpdate = {};
|
||||
const newMaxRadioContacts = parseInt(maxRadioContacts, 10);
|
||||
if (!isNaN(newMaxRadioContacts) && newMaxRadioContacts !== appSettings?.max_radio_contacts) {
|
||||
await onSaveAppSettings({ max_radio_contacts: newMaxRadioContacts });
|
||||
update.max_radio_contacts = newMaxRadioContacts;
|
||||
}
|
||||
if (experimentalChannelDoubleSend !== appSettings?.experimental_channel_double_send) {
|
||||
update.experimental_channel_double_send = experimentalChannelDoubleSend;
|
||||
}
|
||||
if (Object.keys(update).length > 0) {
|
||||
await onSaveAppSettings(update);
|
||||
}
|
||||
toast.success('Connectivity settings saved');
|
||||
} catch (err) {
|
||||
@@ -756,6 +765,27 @@ export function SettingsModal({
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-md space-y-3">
|
||||
<p className="text-sm text-yellow-500">
|
||||
<strong>Experimental:</strong> Adds a duplicate channel send after a 3-second
|
||||
delay, using the exact same timestamp bytes.
|
||||
</p>
|
||||
<label className="flex items-center gap-3 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={experimentalChannelDoubleSend}
|
||||
onChange={(e) => setExperimentalChannelDoubleSend(e.target.checked)}
|
||||
className="w-4 h-4 rounded border-input accent-primary"
|
||||
/>
|
||||
<span className="text-sm">Always send channel messages twice</span>
|
||||
</label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
This increases channel airtime and adds a 3-second second-attempt delay. Most
|
||||
clients deduplicate repeats by payload and timestamp, but behavior can vary by
|
||||
firmware/client.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button onClick={handleSaveConnectivity} disabled={loading} className="w-full">
|
||||
{loading ? 'Saving...' : 'Save Settings'}
|
||||
</Button>
|
||||
|
||||
@@ -162,6 +162,7 @@ const baseConfig = {
|
||||
|
||||
const baseSettings = {
|
||||
max_radio_contacts: 200,
|
||||
experimental_channel_double_send: false,
|
||||
favorites: [] as Array<{ type: 'channel' | 'contact'; id: string }>,
|
||||
auto_decrypt_dm_on_advert: false,
|
||||
sidebar_sort_order: 'recent' as const,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { SettingsModal } from '../components/SettingsModal';
|
||||
import type { AppSettings, HealthStatus, RadioConfig } from '../types';
|
||||
import type { AppSettings, AppSettingsUpdate, HealthStatus, RadioConfig } from '../types';
|
||||
|
||||
const baseConfig: RadioConfig = {
|
||||
public_key: 'aa'.repeat(32),
|
||||
@@ -29,6 +29,7 @@ const baseHealth: HealthStatus = {
|
||||
|
||||
const baseSettings: AppSettings = {
|
||||
max_radio_contacts: 200,
|
||||
experimental_channel_double_send: false,
|
||||
favorites: [],
|
||||
auto_decrypt_dm_on_advert: false,
|
||||
sidebar_sort_order: 'recent',
|
||||
@@ -40,7 +41,7 @@ const baseSettings: AppSettings = {
|
||||
|
||||
function renderModal(overrides?: {
|
||||
appSettings?: AppSettings;
|
||||
onSaveAppSettings?: (update: { max_radio_contacts?: number }) => Promise<void>;
|
||||
onSaveAppSettings?: (update: AppSettingsUpdate) => Promise<void>;
|
||||
onRefreshAppSettings?: () => Promise<void>;
|
||||
}) {
|
||||
const onSaveAppSettings = overrides?.onSaveAppSettings ?? vi.fn(async () => {});
|
||||
@@ -120,4 +121,22 @@ describe('SettingsModal', () => {
|
||||
expect(onSaveAppSettings).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('saves experimental channel double-send toggle through onSaveAppSettings', async () => {
|
||||
const { onSaveAppSettings } = renderModal({
|
||||
appSettings: { ...baseSettings, experimental_channel_double_send: false },
|
||||
});
|
||||
|
||||
openConnectivityTab();
|
||||
|
||||
const toggle = screen.getByLabelText('Always send channel messages twice');
|
||||
fireEvent.click(toggle);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Save Settings' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onSaveAppSettings).toHaveBeenCalledWith({
|
||||
experimental_channel_double_send: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -124,6 +124,7 @@ export interface BotConfig {
|
||||
|
||||
export interface AppSettings {
|
||||
max_radio_contacts: number;
|
||||
experimental_channel_double_send: boolean;
|
||||
favorites: Favorite[];
|
||||
auto_decrypt_dm_on_advert: boolean;
|
||||
sidebar_sort_order: 'recent' | 'alpha';
|
||||
@@ -135,6 +136,7 @@ export interface AppSettings {
|
||||
|
||||
export interface AppSettingsUpdate {
|
||||
max_radio_contacts?: number;
|
||||
experimental_channel_double_send?: boolean;
|
||||
auto_decrypt_dm_on_advert?: boolean;
|
||||
sidebar_sort_order?: 'recent' | 'alpha';
|
||||
advert_interval?: number;
|
||||
|
||||
Reference in New Issue
Block a user