Добавить лицензию CC0 1.0

This commit is contained in:
AidarKC
2026-11-16 23:50:28 +03:00
parent 548160f7f8
commit c477560632
39 changed files with 901 additions and 138 deletions
+11 -6
View File
@@ -10,7 +10,7 @@ import { getAttachmentKind } from '../services/attachment-format.js';
import { parseDmTechBlocks } from '../services/dm-tech-blocks.js';
import { loadFullDmHistory, resolveMessageTimeMs } from '../services/dm-history.js';
import { formatClockTime, formatDayLabel } from '../services/channels-ux.js';
import { getChatMessages, getRememberedDmPeer, normalizeDmChatId } from '../state.js';
import { getChatMessages, getRememberedDmPeer, normalizeDmChatId, state } from '../state.js';
import { navigateUp } from '../router.js';
export const pageMeta = { id: 'chat-media-view', get title() { return t('screens.chat_media_view.text_001'); } };
@@ -18,16 +18,21 @@ export const pageMeta = { id: 'chat-media-view', get title() { return t('screens
const monthTitle = (date) => formatDate(date, { month: 'long', year: 'numeric' });
// Все вложения переписки, от новых к старым.
function collectAttachments(chatId) {
function collectAttachments(chatId, currentLogin) {
const media = [];
const files = [];
for (const msg of getChatMessages(chatId)) {
if (msg?.deleted) continue;
const parsed = parseDmTechBlocks(String(msg?.text || ''));
const list = Array.isArray(parsed.fileAttachments) ? parsed.fileAttachments : (parsed.fileAttachment ? [parsed.fileAttachment] : []);
for (const attachment of list) {
if (attachment?.kind === 'voice') continue;
const entry = { attachment, timeMs: resolveMessageTimeMs(msg), from: msg?.from };
for (const item of list) {
if (item?.kind === 'voice') continue;
const timeMs = resolveMessageTimeMs(msg);
const attachment = { ...item,
senderLogin: msg?.from === 'out' ? currentLogin : chatId,
messageTimestampMs: timeMs,
};
const entry = { attachment, timeMs, from: msg?.from };
(isDmInlineMedia(attachment) ? media : files).push(entry);
}
}
@@ -182,7 +187,7 @@ export function render({ navigate, route, chrome }) {
function renderBody() {
if (disposed) return;
const { media, files } = collectAttachments(chatId);
const { media, files } = collectAttachments(chatId, state.session?.login);
for (const [value, { button, label }] of tabButtons) {
const count = value === 'media' ? media.length : files.length;
button.textContent = count ? `${label} · ${count}` : label;