partial fix
This commit is contained in:
@@ -35,8 +35,7 @@
|
||||
|
||||
@can('update', $ticket)
|
||||
<details
|
||||
@if ($hasRunningTimer) wire:poll.1s @endif
|
||||
class="group rounded-xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900"
|
||||
class="group rounded-xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900"
|
||||
data-helpdesk-ticket-controls>
|
||||
<summary
|
||||
class="-mx-4 -mt-4 mb-4 flex cursor-pointer list-none items-center justify-between gap-3 rounded-t-xl bg-indigo-700 px-4 py-4 text-white marker:hidden">
|
||||
@@ -238,14 +237,17 @@
|
||||
(() => {
|
||||
const root = document.querySelector('[data-helpdesk-ticket-controls]');
|
||||
|
||||
if (!root) {
|
||||
if (!root || root.dataset.helpdeskTimerBadgeBound === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
const badge = root.querySelector('[data-helpdesk-running-summary-badge]');
|
||||
const elapsed = root.querySelector('[data-helpdesk-running-summary-elapsed]');
|
||||
root.dataset.helpdeskTimerBadgeBound = 'true';
|
||||
|
||||
if (!badge || !elapsed) {
|
||||
const badge = root.querySelector('[data-helpdesk-running-summary-badge]');
|
||||
const summaryElapsed = root.querySelector('[data-helpdesk-running-summary-elapsed]');
|
||||
const panelElapsed = root.querySelector('[data-dusk="ticket-running-elapsed-time"]');
|
||||
|
||||
if (!badge || !summaryElapsed) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -258,11 +260,9 @@
|
||||
return date.toISOString().substring(11, 19);
|
||||
};
|
||||
|
||||
const readExistingElapsedSeconds = () => {
|
||||
const parts = String(elapsed.textContent || '00:00:00')
|
||||
.trim()
|
||||
.split(':')
|
||||
.map((part) => Number.parseInt(part, 10));
|
||||
const readElapsedSeconds = () => {
|
||||
const value = String(panelElapsed?.textContent || summaryElapsed.textContent || '00:00:00').trim();
|
||||
const parts = value.split(':').map((part) => Number.parseInt(part, 10));
|
||||
|
||||
if (parts.length !== 3 || parts.some(Number.isNaN)) {
|
||||
return 0;
|
||||
@@ -276,7 +276,7 @@
|
||||
badge.classList.add('inline-flex');
|
||||
|
||||
if (!startedAt) {
|
||||
startedAt = Date.now() - (readExistingElapsedSeconds() * 1000);
|
||||
startedAt = Date.now() - (readElapsedSeconds() * 1000);
|
||||
}
|
||||
|
||||
if (interval) {
|
||||
@@ -284,7 +284,13 @@
|
||||
}
|
||||
|
||||
interval = setInterval(() => {
|
||||
elapsed.textContent = formatElapsed(Math.floor((Date.now() - startedAt) / 1000));
|
||||
const display = formatElapsed(Math.floor((Date.now() - startedAt) / 1000));
|
||||
|
||||
summaryElapsed.textContent = display;
|
||||
|
||||
if (panelElapsed) {
|
||||
panelElapsed.textContent = display;
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
@@ -300,11 +306,11 @@
|
||||
};
|
||||
|
||||
const syncRunningState = () => {
|
||||
const timerPanel = root.querySelector('[data-helpdesk-running-timer]');
|
||||
const timerText = root.textContent.toLowerCase();
|
||||
const isRunning = Boolean(timerPanel) || timerText.includes('timer started') || timerText.includes('running');
|
||||
const hasTimerPanel = Boolean(root.querySelector('[data-helpdesk-running-timer]'));
|
||||
const text = root.textContent.toLowerCase();
|
||||
const running = hasTimerPanel || text.includes('timer started') || text.includes('running');
|
||||
|
||||
if (isRunning) {
|
||||
if (running) {
|
||||
showBadge();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user