SHA256
Исправить регистр ключей и ответные связи
This commit is contained in:
@@ -2213,7 +2213,9 @@
|
||||
"text_066": "Subscribed",
|
||||
"text_067": "Subscribed.",
|
||||
"text_070": "Signed.",
|
||||
"text_071": "Category of notifications"
|
||||
"text_071": "Category of notifications",
|
||||
"text_072": "Add close friend in return",
|
||||
"text_073": "You are close friends now"
|
||||
},
|
||||
"user_profile_list_view": {
|
||||
"text_002": "Message",
|
||||
|
||||
@@ -2346,7 +2346,9 @@
|
||||
"text_068": "Подписался",
|
||||
"text_069": "Подписалась",
|
||||
"text_070": "Подписался(-ась)",
|
||||
"text_071": "Категория уведомлений"
|
||||
"text_071": "Категория уведомлений",
|
||||
"text_072": "Добавить в близкие друзья в ответ",
|
||||
"text_073": "Теперь вы близкие друзья"
|
||||
},
|
||||
"user_profile_list_view": {
|
||||
"text_001": "Список",
|
||||
|
||||
@@ -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' });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -32,10 +32,11 @@
|
||||
border-bottom: 1px solid var(--divider-soft);
|
||||
}
|
||||
|
||||
.notification-card__head { display: flex; align-items: baseline; gap: var(--space-2); min-width: 0; }
|
||||
.notification-card__head { display: flex; align-items: start; gap: var(--space-2); min-width: 0; }
|
||||
|
||||
.notification-card__identity { display: grid; flex: 1 1 auto; min-width: 0; gap: 1px; }
|
||||
|
||||
.notification-card__name {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
color: var(--text-primary);
|
||||
font-size: var(--text-md);
|
||||
@@ -45,7 +46,17 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.notification-card__time { flex: 0 0 auto; color: var(--text-secondary); font-size: var(--text-xs); }
|
||||
.notification-card__login {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-xs);
|
||||
line-height: var(--leading-xs);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.notification-card__time { flex: 0 0 auto; padding-top: 2px; color: var(--text-secondary); font-size: var(--text-xs); }
|
||||
|
||||
/* Непрочитанное: точка-акцент перед временем. */
|
||||
.notification-card--new .notification-card__time::before {
|
||||
|
||||
@@ -76,6 +76,25 @@ test('HEADER и PostgreSQL требуют неизменяемого регис
|
||||
assert.match(migration, /NEW\.login IS DISTINCT FROM OLD\.login/);
|
||||
});
|
||||
|
||||
test('runtime-state блокчейна использует normalized_login, не отображаемое написание', () => {
|
||||
const migration = readFileSync(new URL('../../SHiNE-server/shine-server-db/src/main/resources/postgres/migration_v43.sql', import.meta.url), 'utf8');
|
||||
const state = readFileSync(new URL('../../SHiNE-server/shine-server-db/src/main/java/shine/db/entities/BlockchainStateEntry.java', import.meta.url), 'utf8');
|
||||
assert.match(migration, /FOREIGN KEY \(login\) REFERENCES user_identity_current\(normalized_login\)/);
|
||||
assert.match(migration, /SET login = LOWER\(BTRIM\(login\)\)/);
|
||||
assert.match(migration, /NEW\.login := LOWER\(BTRIM\(NEW\.login\)\)/);
|
||||
assert.match(state, /toLowerCase\(Locale\.ROOT\)/);
|
||||
});
|
||||
|
||||
test('адресат уведомления хранится и ищется по normalized_login', () => {
|
||||
const migration = readFileSync(new URL('../../SHiNE-server/shine-server-db/src/main/resources/postgres/migration_v44.sql', import.meta.url), 'utf8');
|
||||
const dao = readFileSync(new URL('../../SHiNE-server/shine-server-db/src/main/java/shine/db/dao/UserNotificationsStateDAO.java', import.meta.url), 'utf8');
|
||||
assert.match(migration, /SET owner_login = LOWER\(BTRIM\(owner_login\)\)/);
|
||||
assert.match(migration, /NEW\.owner_login := LOWER\(BTRIM\(NEW\.owner_login\)\)/);
|
||||
assert.match(dao, /ps\.setString\(i\+\+, normalizedLogin\(e\.getOwnerLogin\(\)\)\)/);
|
||||
assert.match(dao, /ps\.setString\(1, normalizedLogin\(ownerLogin\)\)/);
|
||||
assert.match(dao, /toLowerCase\(Locale\.ROOT\)/);
|
||||
});
|
||||
|
||||
test('лента, список подписок и дерево обсуждения возвращают оригинальный регистр автора', () => {
|
||||
const base = new URL('../../SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/channels/', import.meta.url);
|
||||
const read = (file) => readFileSync(new URL(file, base), 'utf8');
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const page = readFileSync(new URL('../js/pages/notifications-view.js', import.meta.url), 'utf8');
|
||||
const css = readFileSync(new URL('../styles/features/notifications.css', import.meta.url), 'utf8');
|
||||
|
||||
test('уведомление показывает логин автора под отображаемым именем', () => {
|
||||
assert.match(page, /notification-card__login/);
|
||||
assert.match(page, /login\.textContent = item\.sourceLogin/);
|
||||
assert.match(css, /\.notification-card__login/);
|
||||
});
|
||||
|
||||
test('ответная связь повторяет тип входящей связи', () => {
|
||||
assert.match(page, /CONNECTION_CLOSE_FRIEND[\s\S]*\? 'close_friend'[\s\S]*: 'friend'/);
|
||||
assert.match(page, /kind, enabled: true/);
|
||||
assert.match(page, /text_072/);
|
||||
assert.match(page, /text_073/);
|
||||
});
|
||||
Reference in New Issue
Block a user