Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/contacts/ContactBulkTagDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export function ContactBulkTagDialog({
const toggleTag = (tag: string) => {
setSelectedTags(prev => {
const next = new Set(prev);
next.has(tag) ? next.delete(tag) : next.add(tag);
if (next.has(tag)) next.delete(tag);
else next.add(tag);
return next;
});
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/contacts/ContactGroupedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export function ContactGroupedList({
const toggleGroup = (key: string) => {
setCollapsed(prev => {
const next = new Set(prev);
next.has(key) ? next.delete(key) : next.add(key);
if (next.has(key)) next.delete(key);
else next.add(key);
return next;
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/contacts/SafeHtml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const SafeHtml: React.FC<SafeHtmlProps> = ({
}

const Tag = inline ? 'span' : 'div';
// eslint-disable-next-line react/no-danger
// dangerouslySetInnerHTML é seguro aqui: input passou por DOMPurify acima
return <Tag className={className} dangerouslySetInnerHTML={{ __html: sanitized }} />;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export function EnhancedProgressiveDisclosure({ sections, renderWidget, onRefres
const toggleSection = (id: string) => {
setOpenSections(prev => {
const next = new Set(prev);
next.has(id) ? next.delete(id) : next.add(id);
if (next.has(id)) next.delete(id);
else next.add(id);
return next;
});
};
Expand Down
7 changes: 4 additions & 3 deletions src/components/settings/media-library/useMediaLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export function useMediaLibrary(type: MediaType) {
return matchSearch && matchCategory;
});

const toggleSelect = (id: string) => { setSelected(prev => { const next = new Set(prev); next.has(id) ? next.delete(id) : next.add(id); return next; }); };
const toggleSelectAll = () => { selected.size === filtered.length ? setSelected(new Set()) : setSelected(new Set(filtered.map(i => i.id))); };
const toggleSelect = (id: string) => { setSelected(prev => { const next = new Set(prev); if (next.has(id)) next.delete(id); else next.add(id); return next; }); };
const toggleSelectAll = () => { if (selected.size === filtered.length) setSelected(new Set()); else setSelected(new Set(filtered.map(i => i.id))); };

const handleToggleFavorite = async (item: MediaItem) => {
const newValue = !item.is_favorite;
Expand Down Expand Up @@ -183,7 +183,8 @@ export function useMediaLibrary(type: MediaType) {
setReclassifying(false);
setSelected(new Set());
const msg = `${updated}/${toReclassify.length} itens reclassificados com IA`;
errors > 0 ? toast.info(`${msg} (${errors} erros)`) : toast.success(msg);
if (errors > 0) toast.info(`${msg} (${errors} erros)`);
else toast.success(msg);
};

const handleSingleCategoryChange = async (item: MediaItem, newCategory: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function TranscriptionsHistoryView() {
return grouped;
}, [filteredTranscriptions]);

const toggleContact = (id: string) => setExpandedContacts(prev => { const next = new Set(prev); next.has(id) ? next.delete(id) : next.add(id); return next; });
const toggleContact = (id: string) => setExpandedContacts(prev => { const next = new Set(prev); if (next.has(id)) next.delete(id); else next.add(id); return next; });
const expandAll = () => setExpandedContacts(new Set(Object.keys(groupedByContact)));
const collapseAll = () => setExpandedContacts(new Set());

Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Command = React.forwardRef<
));
Command.displayName = CommandPrimitive.displayName;

interface CommandDialogProps extends DialogProps {}
type CommandDialogProps = DialogProps;

const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";

import { cn } from "@/lib/utils";

export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;

const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(({ className, ...props }, ref) => {
return (
Expand Down
3 changes: 2 additions & 1 deletion src/features/inbox/components/AudioRecorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export function AudioRecorder({ onSend, onCancel }: AudioRecorderProps) {
if (isRecording || isPaused) {
if (e.key === ' ' || e.key === 'p' || e.key === 'P') {
e.preventDefault();
isPaused ? resumeRecording() : pauseRecording();
if (isPaused) resumeRecording();
else pauseRecording();
}
if (e.key === 'Escape') {
e.preventDefault();
Expand Down
3 changes: 2 additions & 1 deletion src/features/inbox/components/useFileUploadLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ export function useFileUploadLogic(opts: {
setCurrentQueueIndex(i);
if (fileQueue[i].validation.valid) {
const success = await sendSingleQueueFile(fileQueue[i], i);
success ? successCount++ : errorCount++;
if (success) successCount++;
else errorCount++;
if (i < fileQueue.length - 1) await new Promise(r => setTimeout(r, 500));
} else { errorCount++; }
}
Expand Down
2 changes: 0 additions & 2 deletions src/features/inbox/hooks/useRealtimeInbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ export function useRealtimeInbox() {
} else {
await sendMessage(contactId, content);
}
} catch (err) {
throw err;
} finally {
await refreshActiveConversation();
}
Expand Down
5 changes: 4 additions & 1 deletion src/features/inbox/hooks/useSipClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ export function useSipClient() {

const hangUp = useCallback(() => {
if (sessionRef.current) {
try { sessionRef.current.state === SessionState.Established ? sessionRef.current.bye() : sessionRef.current.cancel(); } catch (err) { log.error('Hangup error:', err); }
try {
if (sessionRef.current.state === SessionState.Established) sessionRef.current.bye();
else sessionRef.current.cancel();
} catch (err) { log.error('Hangup error:', err); }
sessionRef.current = null;
}
stopTimer(); setCallStatus('idle'); callStatusRef.current = 'idle'; setIsMuted(false);
Expand Down
8 changes: 6 additions & 2 deletions src/hooks/useAutomations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ export function useAutomations({
if (!rules.length) return;

// Pega últimas 10 msgs do FATOR X
const { data: msgs } = await getClient()?.rpc("rpc_list_messages", {
const client = getClient();
if (!client) return;
const { data: msgs } = await client.rpc("rpc_list_messages", {
p_remote_jid: remoteJid,
p_instance: instanceName,
p_limit: 10,
Expand All @@ -100,7 +102,9 @@ export function useAutomations({
let addedTags: string[] = [];
let removedTags: string[] = [];
try {
const { data: contact } = await getClient()?.rpc("rpc_get_contact", {
const client2 = getClient();
if (!client2) return;
const { data: contact } = await client2.rpc("rpc_get_contact", {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
p_remote_jid: remoteJid,
p_instance: instanceName,
} as any);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/usePerformanceOptimizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export function useNetworkStatus() {
window.addEventListener('offline', handleOffline);

// Connection API
const connection = (navigator as Navigator & { connection?: { effectiveType?: string; saveData?: boolean; addEventListener?: Function; removeEventListener?: Function } }).connection;
const connection = (navigator as Navigator & { connection?: { effectiveType?: string; saveData?: boolean; addEventListener?: (type: string, listener: () => void) => void; removeEventListener?: (type: string, listener: () => void) => void } }).connection;
if (connection) {
Comment on lines +211 to 212
setConnectionType(connection.effectiveType);
setIsSlowConnection(
Expand Down
9 changes: 4 additions & 5 deletions src/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ class Logger {

/** Log with explicit correlation ID for request tracing */
withCorrelation(correlationId: string) {
const self = this;
return {
debug: (msg: string, ...a: unknown[]) => self.debug(`[cid:${correlationId}] ${msg}`, ...a),
info: (msg: string, ...a: unknown[]) => self.info(`[cid:${correlationId}] ${msg}`, ...a),
warn: (msg: string, ...a: unknown[]) => self.warn(`[cid:${correlationId}] ${msg}`, ...a),
error: (msg: string, ...a: unknown[]) => self.error(`[cid:${correlationId}] ${msg}`, ...a),
debug: (msg: string, ...a: unknown[]) => this.debug(`[cid:${correlationId}] ${msg}`, ...a),
info: (msg: string, ...a: unknown[]) => this.info(`[cid:${correlationId}] ${msg}`, ...a),
warn: (msg: string, ...a: unknown[]) => this.warn(`[cid:${correlationId}] ${msg}`, ...a),
error: (msg: string, ...a: unknown[]) => this.error(`[cid:${correlationId}] ${msg}`, ...a),
};
}
}
Expand Down
3 changes: 2 additions & 1 deletion tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Config } from "tailwindcss";
import tailwindcssAnimate from "tailwindcss-animate";

export default {
darkMode: ["class"],
Expand Down Expand Up @@ -317,5 +318,5 @@ export default {
},
},
},
plugins: [require("tailwindcss-animate")],
plugins: [tailwindcssAnimate],
} satisfies Config;
Loading