Исправить регистр ключей и ответные связи

This commit is contained in:
AidarKC
2026-11-19 18:45:57 +03:00
parent 0274183730
commit 8f3b81c368
13 changed files with 210 additions and 23 deletions
+35 -8
View File
@@ -57,6 +57,24 @@ function actionLabel(item, activeTab) {
: eventActionLabel(item.sourceMsgSubType, gender);
}
function reciprocalRelationKind(item) {
return Number(item?.connectionTypeCode ?? item?.sourceMsgSubType) === CONNECTION_CLOSE_FRIEND
? 'close_friend'
: 'friend';
}
function reciprocalRelationLabel(kind) {
return kind === 'close_friend'
? t('screens.notifications_view.text_072')
: t('screens.notifications_view.text_009');
}
function reciprocalRelationSuccessLabel(kind) {
return kind === 'close_friend'
? t('screens.notifications_view.text_073')
: t('screens.notifications_view.text_015');
}
export const pageMeta = { id: 'notifications-view', get title() { return t('screens.notifications_view.text_001'); } };
function normalizeItem(item) {
@@ -192,10 +210,19 @@ function renderHead(item) {
|| item.sourceLogin || t('screens.notifications_view.text_030');
const head = document.createElement('div');
head.className = 'notification-card__head';
const identity = document.createElement('div');
identity.className = 'notification-card__identity';
const name = document.createElement('strong');
name.className = 'notification-card__name';
name.textContent = fullName;
head.append(name);
identity.append(name);
if (item.sourceLogin) {
const login = document.createElement('span');
login.className = 'notification-card__login';
login.textContent = item.sourceLogin;
identity.append(login);
}
head.append(identity);
const time = document.createElement('span');
time.className = 'notification-card__time';
time.textContent = formatListTime(item.createdAtMs);
@@ -301,8 +328,7 @@ function renderItem(item, activeTab, navigate) {
function refreshItemRow(row, item, activeTab) {
if (!row?.isConnected) return;
row.querySelector('.notification-avatar')?.replaceWith(renderAvatar(item));
const name = row.querySelector('.notification-card__name');
if (name) name.textContent = renderHead(item).querySelector('.notification-card__name').textContent;
row.querySelector('.notification-card__head')?.replaceWith(renderHead(item));
const action = row.querySelector('.notification-card__action');
if (action && activeTab !== 'replies') action.textContent = actionLabel(item, activeTab);
if (activeTab === 'replies' && item.engagement && !row.querySelector('.notification-engagement')) {
@@ -453,24 +479,25 @@ export function render({ navigate, chrome } = {}) {
const row = rowByItem.get(item);
const body = row?.querySelector('.notification-card__body');
if (!body) continue;
const kind = reciprocalRelationKind(item);
const button = document.createElement('button');
button.type = 'button';
button.className = 'secondary-btn notification-card__answer';
button.textContent = t('screens.notifications_view.text_009');
button.textContent = reciprocalRelationLabel(kind);
button.addEventListener('click', async (event) => {
event.stopPropagation();
button.disabled = true;
button.textContent = t('screens.notifications_view.text_010');
try {
await authService.setUserRelation({ login: self, toLogin: login, kind: 'friend', enabled: true, storagePwd: state.session.storagePwdInMemory });
await authService.setUserRelation({ login: self, toLogin: login, kind, enabled: true, storagePwd: state.session.storagePwdInMemory });
const done = document.createElement('span');
done.className = 'notification-card__answered';
done.innerHTML = `${iconHtml('check')}<span>${th('screens.notifications_view.text_046')}</span>`;
done.innerHTML = `${iconHtml('check')}<span>${th(reciprocalRelationSuccessLabel(kind))}</span>`;
button.replaceWith(done);
showToast(t('screens.notifications_view.text_015'));
showToast(reciprocalRelationSuccessLabel(kind));
} catch (error) {
button.disabled = false;
button.textContent = t('screens.notifications_view.text_011');
button.textContent = reciprocalRelationLabel(kind);
showToast(toUserMessage(error, t('screens.notifications_view.text_016')), { kind: 'error' });
}
});