SHA256
Вернуть очередь файлов с подписью и срок хранения вложений в личке
Коммит780ca539(18.11) случайно удалил из chat-view.js функции из2dd0ed6d(17.11). Возвращены поверх текущего main (подпись в sendFileAttachmentMessage уже была добавлена вместе с «Поделиться»): - выбранные файлы копятся в очереди над полем ввода, лишний убирается, текст поля уходит подписью, всё отправляется одним сообщением; - если не удалась загрузка — очередь и подпись остаются для повтора; если файлы загружены, а DM не ушёл — повтор без новой загрузки; - у вложений DM v3 строка «Вложение доступно ещё N дн.», пока срок не истёк (срок — из DM_FILE_RETENTION_MS); - ключи file_remove, remaining_less_day, remaining_days (ru/en). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
client.version=1.21.1
|
client.version=1.21.2
|
||||||
server.version=1.17.0
|
server.version=1.17.0
|
||||||
|
|||||||
@@ -77,12 +77,17 @@ DM: серверный API, подпись и бинарный контейне
|
|||||||
|
|
||||||
### Вложения и запись голосового в UI (17.11.2026)
|
### Вложения и запись голосового в UI (17.11.2026)
|
||||||
|
|
||||||
В личной переписке выбранные файлы остаются в очереди у поля ввода: можно
|
В личной переписке выбранные файлы остаются в очереди над полем ввода: можно
|
||||||
дописать подпись, убрать файл и отправить всё одним сообщением. Текст
|
дописать подпись, убрать файл и отправить всё одним сообщением. Текст
|
||||||
показывается под вложением. У вложений DM v3
|
показывается под вложением. Если не удалась загрузка, очередь и подпись
|
||||||
показывается оставшийся срок хранения на основе `at` (14 дней). Текст в
|
остаются для повтора; если файлы загружены, а сообщение не ушло, предлагается
|
||||||
|
повтор без новой загрузки. У вложений DM v3 показывается оставшийся срок
|
||||||
|
хранения на основе `at` (14 дней), пока он не истёк. Текст в
|
||||||
поле ввода переключает кнопку микрофона в кнопку отправки текста.
|
поле ввода переключает кнопку микрофона в кнопку отправки текста.
|
||||||
|
|
||||||
|
Очередь и срок хранения были случайно удалены коммитом `780ca539` (18.11.2026)
|
||||||
|
и возвращены 29.11.2026.
|
||||||
|
|
||||||
### Голосовые: волна и жесты записи (29.11.2026)
|
### Голосовые: волна и жесты записи (29.11.2026)
|
||||||
|
|
||||||
Запись ведёт `shine-UI/js/components/dm-voice-recorder.js`, пузырь —
|
Запись ведёт `shine-UI/js/components/dm-voice-recorder.js`, пузырь —
|
||||||
|
|||||||
@@ -1021,7 +1021,9 @@
|
|||||||
"text_005": "File downloaded",
|
"text_005": "File downloaded",
|
||||||
"text_006": "file",
|
"text_006": "file",
|
||||||
"text_007": "Download {value1}",
|
"text_007": "Download {value1}",
|
||||||
"file_expired": "File no longer available: encrypted attachments are kept for up to 14 days."
|
"file_expired": "File no longer available: encrypted attachments are kept for up to 14 days.",
|
||||||
|
"remaining_less_day": "Attachment available for less than a day",
|
||||||
|
"remaining_days": "Attachment available for {value1} more days"
|
||||||
},
|
},
|
||||||
"palette_editor": {
|
"palette_editor": {
|
||||||
"text_001": "Failed to read palette, please make sure the whole text is copied.",
|
"text_001": "Failed to read palette, please make sure the whole text is copied.",
|
||||||
@@ -2296,6 +2298,7 @@
|
|||||||
"resume": "Resume recording",
|
"resume": "Resume recording",
|
||||||
"pause_playback": "Pause voice message"
|
"pause_playback": "Pause voice message"
|
||||||
},
|
},
|
||||||
|
"file_remove": "Remove file {value1}",
|
||||||
"text_002": "Muted",
|
"text_002": "Muted",
|
||||||
"text_015": "Search",
|
"text_015": "Search",
|
||||||
"text_020": "Clear history",
|
"text_020": "Clear history",
|
||||||
|
|||||||
@@ -1021,7 +1021,9 @@
|
|||||||
"text_005": "Файл скачан",
|
"text_005": "Файл скачан",
|
||||||
"text_006": "файл",
|
"text_006": "файл",
|
||||||
"text_007": "Скачать {value1}",
|
"text_007": "Скачать {value1}",
|
||||||
"file_expired": "Файл больше недоступен: зашифрованные вложения хранятся не более 14 дней."
|
"file_expired": "Файл больше недоступен: зашифрованные вложения хранятся не более 14 дней.",
|
||||||
|
"remaining_less_day": "Вложение доступно ещё менее дня",
|
||||||
|
"remaining_days": "Вложение доступно ещё {value1} дн."
|
||||||
},
|
},
|
||||||
"palette_editor": {
|
"palette_editor": {
|
||||||
"text_001": "Не удалось прочитать палитру: проверьте, что текст скопирован целиком.",
|
"text_001": "Не удалось прочитать палитру: проверьте, что текст скопирован целиком.",
|
||||||
@@ -2429,6 +2431,7 @@
|
|||||||
"resume": "Продолжить запись",
|
"resume": "Продолжить запись",
|
||||||
"pause_playback": "Приостановить голосовое сообщение"
|
"pause_playback": "Приостановить голосовое сообщение"
|
||||||
},
|
},
|
||||||
|
"file_remove": "Убрать файл {value1}",
|
||||||
"text_001": "Чат",
|
"text_001": "Чат",
|
||||||
"text_002": "Без звука",
|
"text_002": "Без звука",
|
||||||
"text_003": "Показать связи",
|
"text_003": "Показать связи",
|
||||||
|
|||||||
+100
-16
@@ -43,7 +43,7 @@ import {
|
|||||||
} from '../services/dm-file-service.js';
|
} from '../services/dm-file-service.js';
|
||||||
import { createAttachmentCarouselElement } from '../services/attachment-format.js';
|
import { createAttachmentCarouselElement } from '../services/attachment-format.js';
|
||||||
import { createDmFileAttachmentCard, createDmExpiredAttachmentCard, isDmInlineMedia, resolveDmMediaUrl } from '../components/dm-attachments.js';
|
import { createDmFileAttachmentCard, createDmExpiredAttachmentCard, isDmInlineMedia, resolveDmMediaUrl } from '../components/dm-attachments.js';
|
||||||
import { isDmFileExpired } from '../services/dm-file-service.js';
|
import { DM_FILE_RETENTION_MS, isDmFileExpired } from '../services/dm-file-service.js';
|
||||||
import {
|
import {
|
||||||
DM_HISTORY_PAGE_SIZE,
|
DM_HISTORY_PAGE_SIZE,
|
||||||
isDmHistoryFullyLoaded,
|
isDmHistoryFullyLoaded,
|
||||||
@@ -1215,6 +1215,23 @@ function renderLog(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
bubble.append(attachmentsWrap);
|
bubble.append(attachmentsWrap);
|
||||||
|
// Вложения DM v3 живут 14 дней: показываем остаток, пока срок не вышел.
|
||||||
|
// Истёкшие и так отрисованы карточкой «файл больше недоступен».
|
||||||
|
const expiresAt = dmAttachments
|
||||||
|
.filter((item) => Number(item?.version || 1) >= 3)
|
||||||
|
.map((item) => Number(item.uploadedAtMs || item.messageTimestampMs || 0))
|
||||||
|
.filter((uploadedAt) => uploadedAt > 0)
|
||||||
|
.map((uploadedAt) => uploadedAt + DM_FILE_RETENTION_MS);
|
||||||
|
const remaining = expiresAt.length ? Math.min(...expiresAt) - Date.now() : 0;
|
||||||
|
if (remaining > 0) {
|
||||||
|
const dayMs = 24 * 60 * 60 * 1000;
|
||||||
|
const expiry = document.createElement('div');
|
||||||
|
expiry.className = 'dm-attachment-expiry';
|
||||||
|
expiry.textContent = remaining < dayMs
|
||||||
|
? t('screens.dm_attachments.remaining_less_day')
|
||||||
|
: t('screens.dm_attachments.remaining_days', { value1: Math.ceil(remaining / dayMs) });
|
||||||
|
bubble.append(expiry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const textNode = document.createElement('div');
|
const textNode = document.createElement('div');
|
||||||
@@ -1815,6 +1832,8 @@ export function render({ navigate, route, chrome }) {
|
|||||||
<button class="ghost-btn dm-edit-banner__close" type="button" id="chat-edit-cancel" title="${th('screens.chat_view.text_112')}">✕</button>
|
<button class="ghost-btn dm-edit-banner__close" type="button" id="chat-edit-cancel" title="${th('screens.chat_view.text_112')}">✕</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="emoji-picker-slot" id="chat-emoji-picker-slot" hidden></div>
|
<div class="emoji-picker-slot" id="chat-emoji-picker-slot" hidden></div>
|
||||||
|
<!-- Выбранные файлы ждут здесь: можно убрать лишний и дописать подпись, отправка – одним сообщением. -->
|
||||||
|
<div class="dm-file-queue" id="chat-file-queue" hidden></div>
|
||||||
<!-- Капсула как строка ответа в обсуждениях. В покое – один ряд: фото · текст · смайлик · отправка.
|
<!-- Капсула как строка ответа в обсуждениях. В покое – один ряд: фото · текст · смайлик · отправка.
|
||||||
При вводе текст занимает весь верхний ряд, а все кнопки – нижний (как в терминале Claude). -->
|
При вводе текст занимает весь верхний ряд, а все кнопки – нижний (как в терминале Claude). -->
|
||||||
<div class="dm-composer-bar">
|
<div class="dm-composer-bar">
|
||||||
@@ -1850,6 +1869,7 @@ export function render({ navigate, route, chrome }) {
|
|||||||
const emojiToggle = form.querySelector('#chat-emoji-toggle');
|
const emojiToggle = form.querySelector('#chat-emoji-toggle');
|
||||||
const fileToggle = form.querySelector('#chat-file-toggle');
|
const fileToggle = form.querySelector('#chat-file-toggle');
|
||||||
const fileInput = form.querySelector('#chat-file-input');
|
const fileInput = form.querySelector('#chat-file-input');
|
||||||
|
const fileQueue = form.querySelector('#chat-file-queue');
|
||||||
// Три входа для вложений: галерея (фото/видео), камера и любой файл – дальше путь один.
|
// Три входа для вложений: галерея (фото/видео), камера и любой файл – дальше путь один.
|
||||||
const attachSources = [
|
const attachSources = [
|
||||||
[fileToggle, fileInput],
|
[fileToggle, fileInput],
|
||||||
@@ -1873,6 +1893,8 @@ export function render({ navigate, route, chrome }) {
|
|||||||
// Создаётся ниже, когда готовы обработчики страницы; до этого кнопка — обычный микрофон.
|
// Создаётся ниже, когда готовы обработчики страницы; до этого кнопка — обычный микрофон.
|
||||||
let voice = null;
|
let voice = null;
|
||||||
let suppressVoiceClick = false;
|
let suppressVoiceClick = false;
|
||||||
|
let queuedFiles = [];
|
||||||
|
let fileSending = false;
|
||||||
|
|
||||||
let historyLoaderTimer = 0;
|
let historyLoaderTimer = 0;
|
||||||
const setHistoryLoadingState = (isLoading) => {
|
const setHistoryLoadingState = (isLoading) => {
|
||||||
@@ -1955,10 +1977,10 @@ export function render({ navigate, route, chrome }) {
|
|||||||
const voiceState = voice?.state || 'idle';
|
const voiceState = voice?.state || 'idle';
|
||||||
const recording = Boolean(voice?.isRecording());
|
const recording = Boolean(voice?.isRecording());
|
||||||
let mode = 'voice';
|
let mode = 'voice';
|
||||||
if (voiceState === 'busy') mode = 'busy';
|
if (voiceState === 'busy' || fileSending) mode = 'busy';
|
||||||
else if (voiceState === 'locked' || voiceState === 'paused') mode = 'voice-send';
|
else if (voiceState === 'locked' || voiceState === 'paused') mode = 'voice-send';
|
||||||
else if (voiceState !== 'idle') mode = 'voice';
|
else if (voiceState !== 'idle') mode = 'voice';
|
||||||
else if (activeEdit || shared || String(input?.value || '').trim()) mode = 'send';
|
else if (activeEdit || shared || queuedFiles.length || String(input?.value || '').trim()) mode = 'send';
|
||||||
|
|
||||||
sendBtn.dataset.mode = mode;
|
sendBtn.dataset.mode = mode;
|
||||||
sendBtn.innerHTML = sendIconMarkup(mode);
|
sendBtn.innerHTML = sendIconMarkup(mode);
|
||||||
@@ -2421,7 +2443,7 @@ export function render({ navigate, route, chrome }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Файлы уже лежат на сервере – повторить можно одно сообщение с ключами, без новой загрузки.
|
// Файлы уже лежат на сервере – повторить можно одно сообщение с ключами, без новой загрузки.
|
||||||
const offerAttachmentsRetry = (attachments, error) => {
|
const offerAttachmentsRetry = (attachments, error, caption = '') => {
|
||||||
showToast(actionErrorText(attachments.length === 1 ? t('screens.chat_view.text_075') : t('screens.chat_view.text_076'), error), {
|
showToast(actionErrorText(attachments.length === 1 ? t('screens.chat_view.text_075') : t('screens.chat_view.text_076'), error), {
|
||||||
kind: 'error',
|
kind: 'error',
|
||||||
action: {
|
action: {
|
||||||
@@ -2429,10 +2451,10 @@ export function render({ navigate, route, chrome }) {
|
|||||||
onClick: async () => {
|
onClick: async () => {
|
||||||
if (disposed) return;
|
if (disposed) return;
|
||||||
try {
|
try {
|
||||||
await sendFileAttachmentMessage(attachments);
|
await sendFileAttachmentMessage(attachments, caption);
|
||||||
if (!disposed) showToast(attachments.length === 1 ? t('screens.chat_view.text_077') : t('screens.chat_view.text_100', { value1: attachments.length }), { timeoutMs: 1300 });
|
if (!disposed) showToast(attachments.length === 1 ? t('screens.chat_view.text_077') : t('screens.chat_view.text_100', { value1: attachments.length }), { timeoutMs: 1300 });
|
||||||
} catch (again) {
|
} catch (again) {
|
||||||
if (!disposed) offerAttachmentsRetry(attachments, again);
|
if (!disposed) offerAttachmentsRetry(attachments, again, caption);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -2495,7 +2517,33 @@ export function render({ navigate, route, chrome }) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSelectedFiles = async (fileList) => {
|
// Очередь вложений у поля ввода: файлы копятся, лишний можно убрать, подпись берётся из поля.
|
||||||
|
const renderQueuedFiles = () => {
|
||||||
|
fileQueue.replaceChildren();
|
||||||
|
fileQueue.hidden = !queuedFiles.length;
|
||||||
|
queuedFiles.forEach((file, index) => {
|
||||||
|
const fileName = String(file?.name || 'file');
|
||||||
|
const chip = document.createElement('span');
|
||||||
|
chip.className = 'dm-file-queue__chip';
|
||||||
|
const name = document.createElement('span');
|
||||||
|
name.textContent = fileName;
|
||||||
|
const remove = document.createElement('button');
|
||||||
|
remove.type = 'button';
|
||||||
|
remove.textContent = '✕';
|
||||||
|
remove.disabled = fileSending;
|
||||||
|
remove.setAttribute('aria-label', t('screens.chat_view.file_remove', { value1: fileName }));
|
||||||
|
remove.addEventListener('click', () => {
|
||||||
|
if (fileSending) return;
|
||||||
|
queuedFiles.splice(index, 1);
|
||||||
|
renderQueuedFiles();
|
||||||
|
});
|
||||||
|
chip.append(name, remove);
|
||||||
|
fileQueue.append(chip);
|
||||||
|
});
|
||||||
|
updateSendButtonMode();
|
||||||
|
};
|
||||||
|
|
||||||
|
const queueSelectedFiles = (files) => {
|
||||||
if (shared) return;
|
if (shared) return;
|
||||||
if (!fileTransferEnabled) {
|
if (!fileTransferEnabled) {
|
||||||
showToast(t('screens.chat_view.text_054'), { kind: 'error', timeoutMs: 1800 });
|
showToast(t('screens.chat_view.text_054'), { kind: 'error', timeoutMs: 1800 });
|
||||||
@@ -2505,13 +2553,28 @@ export function render({ navigate, route, chrome }) {
|
|||||||
showToast(t('screens.chat_view.text_055'), { kind: 'error', timeoutMs: 1600 });
|
showToast(t('screens.chat_view.text_055'), { kind: 'error', timeoutMs: 1600 });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const allFiles = Array.from(fileList || []).filter(Boolean);
|
if (queuedFiles.length + files.length > DM_MAX_ATTACHMENTS_PER_MESSAGE) {
|
||||||
if (!allFiles.length) return;
|
|
||||||
if (allFiles.length > DM_MAX_ATTACHMENTS_PER_MESSAGE) {
|
|
||||||
showToast(t('screens.chat_view.text_101', { value1: DM_MAX_ATTACHMENTS_PER_MESSAGE }), { kind: 'error', timeoutMs: 2200 });
|
showToast(t('screens.chat_view.text_101', { value1: DM_MAX_ATTACHMENTS_PER_MESSAGE }), { kind: 'error', timeoutMs: 2200 });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
queuedFiles.push(...files);
|
||||||
|
renderQueuedFiles();
|
||||||
|
};
|
||||||
|
|
||||||
|
const sendQueuedFiles = async () => {
|
||||||
|
if (fileSending || !queuedFiles.length) return;
|
||||||
|
if (!fileTransferEnabled) {
|
||||||
|
showToast(t('screens.chat_view.text_054'), { kind: 'error', timeoutMs: 1800 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activeEdit) {
|
||||||
|
showToast(t('screens.chat_view.text_055'), { kind: 'error', timeoutMs: 1600 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const allFiles = queuedFiles.slice();
|
||||||
|
const caption = String(input?.value || '').trim();
|
||||||
|
fileSending = true;
|
||||||
|
renderQueuedFiles();
|
||||||
attachButtons.forEach((button) => {
|
attachButtons.forEach((button) => {
|
||||||
button.disabled = true;
|
button.disabled = true;
|
||||||
button.classList.add('is-busy');
|
button.classList.add('is-busy');
|
||||||
@@ -2538,13 +2601,27 @@ export function render({ navigate, route, chrome }) {
|
|||||||
attachments.push(attachment);
|
attachments.push(attachment);
|
||||||
}
|
}
|
||||||
uploaded = true;
|
uploaded = true;
|
||||||
await sendFileAttachmentMessage(attachments);
|
await sendFileAttachmentMessage(attachments, caption);
|
||||||
|
queuedFiles = [];
|
||||||
|
// Подпись ушла вместе с файлами; если её успели поменять во время загрузки — не трогаем.
|
||||||
|
if (caption && String(input?.value || '').trim() === caption) {
|
||||||
|
input.value = '';
|
||||||
|
autoResizeComposer(input);
|
||||||
|
syncComposerLayout();
|
||||||
|
}
|
||||||
setFileActionVisible(false);
|
setFileActionVisible(false);
|
||||||
showToast(attachments.length === 1 ? t('screens.chat_view.text_078') : t('screens.chat_view.text_103', { value1: attachments.length }), { timeoutMs: 1300 });
|
showToast(attachments.length === 1 ? t('screens.chat_view.text_078') : t('screens.chat_view.text_103', { value1: attachments.length }), { timeoutMs: 1300 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (uploaded) offerAttachmentsRetry(attachments, error);
|
if (uploaded) {
|
||||||
else showToast(actionErrorText(allFiles.length === 1 ? t('screens.chat_view.text_079') : t('screens.chat_view.text_080'), error), { kind: 'error' });
|
// Файлы уже на сервере: повтор отправит то же сообщение без новой загрузки.
|
||||||
|
queuedFiles = [];
|
||||||
|
offerAttachmentsRetry(attachments, error, caption);
|
||||||
|
} else {
|
||||||
|
// Загрузка не удалась: очередь остаётся, повторить можно той же кнопкой «Отправить».
|
||||||
|
showToast(actionErrorText(allFiles.length === 1 ? t('screens.chat_view.text_079') : t('screens.chat_view.text_080'), error), { kind: 'error' });
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
fileSending = false;
|
||||||
attachButtons.forEach((button) => {
|
attachButtons.forEach((button) => {
|
||||||
button.disabled = false;
|
button.disabled = false;
|
||||||
button.classList.remove('is-busy');
|
button.classList.remove('is-busy');
|
||||||
@@ -2553,7 +2630,7 @@ export function render({ navigate, route, chrome }) {
|
|||||||
fileToggle.title = t('screens.chat_view.text_036');
|
fileToggle.title = t('screens.chat_view.text_036');
|
||||||
fileToggle.setAttribute('aria-label', t('dialogs.modals.chat_view.label_035'));
|
fileToggle.setAttribute('aria-label', t('dialogs.modals.chat_view.label_035'));
|
||||||
}
|
}
|
||||||
attachSources.forEach(([, picker]) => { if (picker) picker.value = ''; });
|
renderQueuedFiles();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2809,7 +2886,9 @@ export function render({ navigate, route, chrome }) {
|
|||||||
});
|
});
|
||||||
picker?.addEventListener('change', () => {
|
picker?.addEventListener('change', () => {
|
||||||
const files = Array.from(picker.files || []);
|
const files = Array.from(picker.files || []);
|
||||||
if (files.length) void handleSelectedFiles(files);
|
// Сброс сразу: тот же файл можно выбрать снова, если его убрали из очереди.
|
||||||
|
picker.value = '';
|
||||||
|
if (files.length) queueSelectedFiles(files);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
screen.addEventListener('pointerdown', (event) => {
|
screen.addEventListener('pointerdown', (event) => {
|
||||||
@@ -2873,7 +2952,7 @@ export function render({ navigate, route, chrome }) {
|
|||||||
input.addEventListener('keydown', (event) => {
|
input.addEventListener('keydown', (event) => {
|
||||||
if (!isDmSendEnter(event)) return;
|
if (!isDmSendEnter(event)) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (shared?.files.length || String(input.value || '').trim()) form.requestSubmit();
|
if (shared?.files.length || queuedFiles.length || String(input.value || '').trim()) form.requestSubmit();
|
||||||
});
|
});
|
||||||
|
|
||||||
form.addEventListener('submit', async (event) => {
|
form.addEventListener('submit', async (event) => {
|
||||||
@@ -2883,6 +2962,11 @@ export function render({ navigate, route, chrome }) {
|
|||||||
if (text || shared.files.length) await sendSharedDraft(text);
|
if (text || shared.files.length) await sendSharedDraft(text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (queuedFiles.length) {
|
||||||
|
closeEmojiPicker();
|
||||||
|
await sendQueuedFiles();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
input.value = '';
|
input.value = '';
|
||||||
autoResizeComposer(input);
|
autoResizeComposer(input);
|
||||||
|
|||||||
Reference in New Issue
Block a user