mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-05-04 04:23:04 +02:00
Fix stale closure on existing keys
This commit is contained in:
@@ -98,6 +98,7 @@ export function CrackerPanel({
|
||||
const twoWordModeRef = useRef(false);
|
||||
const undecryptedIdsRef = useRef<Set<number>>(new Set());
|
||||
const seenPayloadsRef = useRef<Set<string>>(new Set());
|
||||
const existingChannelKeysRef = useRef<Set<string>>(new Set());
|
||||
|
||||
// Initialize cracker and NoSleep
|
||||
useEffect(() => {
|
||||
@@ -155,6 +156,10 @@ export function CrackerPanel({
|
||||
[channels]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
existingChannelKeysRef.current = existingChannelKeys;
|
||||
}, [existingChannelKeys]);
|
||||
|
||||
// Filter packets to only undecrypted GROUP_TEXT
|
||||
const undecryptedGroupText = packets.filter(
|
||||
(p) => p.payload_type === 'GROUP_TEXT' && !p.decrypted
|
||||
@@ -365,7 +370,7 @@ export function CrackerPanel({
|
||||
|
||||
// Auto-add channel if not already exists
|
||||
const keyUpper = result.key.toUpperCase();
|
||||
if (!existingChannelKeys.has(keyUpper)) {
|
||||
if (!existingChannelKeysRef.current.has(keyUpper)) {
|
||||
try {
|
||||
const channelName = '#' + result.roomName;
|
||||
await onChannelCreate(channelName, result.key);
|
||||
@@ -426,7 +431,7 @@ export function CrackerPanel({
|
||||
if (isRunningRef.current) {
|
||||
setTimeout(() => processNext(), 100);
|
||||
}
|
||||
}, [existingChannelKeys, onChannelCreate]);
|
||||
}, [onChannelCreate]);
|
||||
|
||||
// Start/stop handlers
|
||||
const handleStart = () => {
|
||||
|
||||
Reference in New Issue
Block a user