Revert "Исправление открытия чата: не закрывать при сбое опроса списка, сохранять активную карточку"
This reverts commit 083eae4059.
This commit is contained in:
+10
-20
@@ -91,10 +91,6 @@
|
||||
};
|
||||
}
|
||||
|
||||
function ticketApiPath(ticketNumber) {
|
||||
return encodeURIComponent(String(ticketNumber ?? ""));
|
||||
}
|
||||
|
||||
function revokeAttachmentUrls() {
|
||||
for (const u of state.blobUrls) {
|
||||
try {
|
||||
@@ -953,9 +949,6 @@
|
||||
await refreshLastMessageSignaturesStaggered();
|
||||
updateBoardUnreadFingerprints();
|
||||
renderTickets();
|
||||
if (state.chatModalOpen && state.currentTicket != null) {
|
||||
reapplyActiveTicketCard(state.currentTicket);
|
||||
}
|
||||
}
|
||||
|
||||
function partitionClientTickets(list) {
|
||||
@@ -1022,24 +1015,22 @@
|
||||
const tnSel = String(ticketNumber).replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
||||
const card = document.querySelector(`.f7-ticket-card[data-ticket-number="${tnSel}"]`);
|
||||
if (card) card.classList.add("f7-ticket-card--active");
|
||||
showError("");
|
||||
openChatModal(ticket);
|
||||
delete state.ticketUnreadByLastMsg[String(ticketNumber)];
|
||||
try {
|
||||
await fetchMessages();
|
||||
} catch (e) {
|
||||
showError(e.message || "Не удалось загрузить сообщения");
|
||||
disconnectTicketSocket();
|
||||
await closeChatModal();
|
||||
return;
|
||||
}
|
||||
await fetchTickets();
|
||||
const row = state.tickets.find((x) => x.ticket_number === ticketNumber);
|
||||
if (row) row.has_unread = false;
|
||||
renderTickets();
|
||||
reapplyActiveTicketCard(ticketNumber);
|
||||
void markClientTicketRead(ticket.ticket_number);
|
||||
connectTicketSocket(ticket.ticket_number);
|
||||
fetchTickets().catch(() => {});
|
||||
} catch (e) {
|
||||
showError(e.message || "Не удалось загрузить сообщения");
|
||||
disconnectTicketSocket();
|
||||
await closeChatModal();
|
||||
}
|
||||
}
|
||||
|
||||
function renderTickets() {
|
||||
@@ -1061,8 +1052,7 @@
|
||||
|
||||
async function fetchMessages() {
|
||||
if (!state.currentTicket) return;
|
||||
const tn = ticketApiPath(state.currentTicket);
|
||||
const response = await fetch(`${apiBase}/api/client/tickets/${tn}/messages`, {
|
||||
const response = await fetch(`${apiBase}/api/client/tickets/${state.currentTicket}/messages`, {
|
||||
headers: clientIdentityHeaders(),
|
||||
});
|
||||
if (!response.ok) throw new Error("Не удалось загрузить сообщения");
|
||||
@@ -1072,7 +1062,7 @@
|
||||
}
|
||||
|
||||
async function fetchClientAttachmentBlob(attachmentId) {
|
||||
const url = `${apiBase}/api/client/tickets/${ticketApiPath(state.currentTicket)}/attachments/${encodeURIComponent(String(attachmentId))}`;
|
||||
const url = `${apiBase}/api/client/tickets/${state.currentTicket}/attachments/${attachmentId}`;
|
||||
const res = await fetch(url, { headers: clientIdentityHeaders() });
|
||||
if (!res.ok) throw new Error("attachment");
|
||||
return res.blob();
|
||||
@@ -1236,7 +1226,7 @@
|
||||
}
|
||||
if (!text && file) text = `📎 ${file.name}`;
|
||||
|
||||
const response = await fetch(`${apiBase}/api/client/tickets/${ticketApiPath(state.currentTicket)}/messages`, {
|
||||
const response = await fetch(`${apiBase}/api/client/tickets/${state.currentTicket}/messages`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -1253,7 +1243,7 @@
|
||||
const form = new FormData();
|
||||
form.append("message_id", String(created.id));
|
||||
form.append("file", file);
|
||||
const attRes = await fetch(`${apiBase}/api/client/tickets/${ticketApiPath(state.currentTicket)}/attachments`, {
|
||||
const attRes = await fetch(`${apiBase}/api/client/tickets/${state.currentTicket}/attachments`, {
|
||||
method: "POST",
|
||||
headers: clientIdentityHeaders(),
|
||||
body: form,
|
||||
|
||||
Reference in New Issue
Block a user