refactor: streamline log update handling in Proxmox Firewall component by simplifying initialization and event listener for improved performance and clarity

This commit is contained in:
2025-12-02 08:16:47 -05:00
parent d0cd87faf1
commit 31b65ef44f

View File

@@ -323,22 +323,18 @@
@if(count($firewallLogs) > 0)
<div
wire:key="firewall-logs-table"
x-data="{
logs: [],
logs: @js($firewallLogs),
searchTerm: '',
sortField: 'timestamp_iso',
sortDirection: 'desc',
initialize(initialLogs) {
this.logs = (initialLogs || []).map((log, index) => ({
index,
...log,
}));
// This is called on x-init
},
updateLogs(newLogs) {
this.logs = (newLogs || []).map((log, index) => ({
index,
...log,
}));
if (!newLogs || newLogs.length === 0) return;
this.logs = newLogs;
},
sort(field) {
if (this.sortField === field) {
@@ -384,12 +380,7 @@
});
},
}"
x-init="
initialize(@js($firewallLogs));
$wire.on('logs-updated', (event) => {
updateLogs(event.logs || event[0]?.logs || event[0] || []);
});
"
@logs-updated.window="updateLogs($event.detail.logs || $event.detail[0]?.logs || $event.detail[0] || [])"
class="space-y-4"
>
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">