SHA256
Ускорить публикацию блоков в Arweave
This commit is contained in:
+112
-7
@@ -2,17 +2,32 @@ package server.archive;
|
|||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import server.sync.ArweavePublishSignal;
|
||||||
|
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/** Fixed-delay publisher. Empty cycles are no-ops. */
|
/**
|
||||||
|
* Publisher с двумя путями доставки:
|
||||||
|
* 1) Turbo — немедленная неблокирующая попытка для только что принятого блока;
|
||||||
|
* 2) плановый fixed-delay цикл — страховочная добивка только зависших pending-записей.
|
||||||
|
*/
|
||||||
public final class ArweaveBlockPublisherScheduler {
|
public final class ArweaveBlockPublisherScheduler {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ArweaveBlockPublisherScheduler.class);
|
private static final Logger log = LoggerFactory.getLogger(ArweaveBlockPublisherScheduler.class);
|
||||||
|
private static final long RETRY_MIN_PENDING_AGE_MS = 60_000L;
|
||||||
private static final AtomicBoolean STARTED = new AtomicBoolean(false);
|
private static final AtomicBoolean STARTED = new AtomicBoolean(false);
|
||||||
|
private static final AtomicBoolean IMMEDIATE_DRAIN_SCHEDULED = new AtomicBoolean(false);
|
||||||
|
private static final ConcurrentLinkedQueue<ArweavePublishSignal.PendingRef> IMMEDIATE_QUEUE = new ConcurrentLinkedQueue<>();
|
||||||
|
private static final ConcurrentHashMap<String, Long> PENDING_SINCE_MS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private static ScheduledExecutorService executor;
|
private static ScheduledExecutorService executor;
|
||||||
|
private static ArweaveBlockPublisherService service;
|
||||||
|
private static ArweaveBlocksConfig config;
|
||||||
|
|
||||||
private ArweaveBlockPublisherScheduler() {}
|
private ArweaveBlockPublisherScheduler() {}
|
||||||
|
|
||||||
@@ -23,15 +38,105 @@ public final class ArweaveBlockPublisherScheduler {
|
|||||||
if (!cfg.publishEnabled()) { log.info("Arweave user-block publisher disabled (mode=none)"); return; }
|
if (!cfg.publishEnabled()) { log.info("Arweave user-block publisher disabled (mode=none)"); return; }
|
||||||
if (!STARTED.compareAndSet(false,true)) return;
|
if (!STARTED.compareAndSet(false,true)) return;
|
||||||
try {
|
try {
|
||||||
ArweaveBlockPublisherService service = new ArweaveBlockPublisherService(cfg);
|
config = cfg;
|
||||||
|
service = new ArweaveBlockPublisherService(cfg);
|
||||||
executor = Executors.newSingleThreadScheduledExecutor(r -> {
|
executor = Executors.newSingleThreadScheduledExecutor(r -> {
|
||||||
Thread t = new Thread(r, "shine-arweave-block-publisher"); t.setDaemon(true); return t;
|
Thread t = new Thread(r, "shine-arweave-block-publisher"); t.setDaemon(true); return t;
|
||||||
});
|
});
|
||||||
Runnable task = () -> { try { service.runCycle(); } catch (Exception e) { log.error("Arweave block publish cycle failed", e); } };
|
|
||||||
executor.scheduleWithFixedDelay(task, 0, cfg.publishIntervalMinutes(), TimeUnit.MINUTES);
|
if (cfg.publishMode() == ArweaveBlocksConfig.PublishMode.TURBO) {
|
||||||
log.info("Arweave user-block publisher enabled: mode={} interval={}m", cfg.publishMode(), cfg.publishIntervalMinutes());
|
ArweavePublishSignal.setListener(ArweaveBlockPublisherScheduler::enqueueImmediateTurboPublish);
|
||||||
} catch (Exception e) { STARTED.set(false); log.error("Arweave user-block publisher failed to start", e); }
|
}
|
||||||
|
|
||||||
|
Runnable retryTask = () -> {
|
||||||
|
try {
|
||||||
|
if (config.publishMode() == ArweaveBlocksConfig.PublishMode.TURBO) {
|
||||||
|
long nowMs = System.currentTimeMillis();
|
||||||
|
service.runRetryCycle(
|
||||||
|
id -> isOldEnoughForRetry(id, nowMs),
|
||||||
|
id -> PENDING_SINCE_MS.remove(idKey(id))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
service.runCycle();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Arweave block publish retry cycle failed", e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
long retryInitialDelayMinutes = cfg.publishMode() == ArweaveBlocksConfig.PublishMode.TURBO
|
||||||
|
? cfg.publishIntervalMinutes()
|
||||||
|
: 0L;
|
||||||
|
executor.scheduleWithFixedDelay(retryTask, retryInitialDelayMinutes, cfg.publishIntervalMinutes(), TimeUnit.MINUTES);
|
||||||
|
log.info("Arweave user-block publisher enabled: mode={} immediateTurbo={} retryInterval={}m retryMinAge={}s",
|
||||||
|
cfg.publishMode(), cfg.publishMode() == ArweaveBlocksConfig.PublishMode.TURBO,
|
||||||
|
cfg.publishIntervalMinutes(), RETRY_MIN_PENDING_AGE_MS / 1000L);
|
||||||
|
} catch (Exception e) {
|
||||||
|
ArweavePublishSignal.clearListener();
|
||||||
|
STARTED.set(false);
|
||||||
|
log.error("Arweave user-block publisher failed to start", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void close() { ScheduledExecutorService e=executor; if(e!=null)e.shutdownNow(); }
|
private static void enqueueImmediateTurboPublish(ArweavePublishSignal.PendingRef item) {
|
||||||
|
if (!STARTED.get() || config == null || config.publishMode() != ArweaveBlocksConfig.PublishMode.TURBO) return;
|
||||||
|
PENDING_SINCE_MS.putIfAbsent(idKey(item.dataItemId()), System.currentTimeMillis());
|
||||||
|
IMMEDIATE_QUEUE.offer(item);
|
||||||
|
scheduleImmediateDrain();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isOldEnoughForRetry(byte[] dataItemId, long nowMs) {
|
||||||
|
Long pendingSince = PENDING_SINCE_MS.get(idKey(dataItemId));
|
||||||
|
// Нет записи в памяти => pending пережил старт процесса и уже считается зависшим.
|
||||||
|
return pendingSince == null || nowMs - pendingSince >= RETRY_MIN_PENDING_AGE_MS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String idKey(byte[] dataItemId) {
|
||||||
|
return Base64.getUrlEncoder().withoutPadding().encodeToString(dataItemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void scheduleImmediateDrain() {
|
||||||
|
ScheduledExecutorService currentExecutor = executor;
|
||||||
|
if (currentExecutor == null || currentExecutor.isShutdown()) return;
|
||||||
|
if (!IMMEDIATE_DRAIN_SCHEDULED.compareAndSet(false, true)) return;
|
||||||
|
try {
|
||||||
|
currentExecutor.execute(ArweaveBlockPublisherScheduler::drainImmediateQueue);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
IMMEDIATE_DRAIN_SCHEDULED.set(false);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void drainImmediateQueue() {
|
||||||
|
try {
|
||||||
|
ArweavePublishSignal.PendingRef item;
|
||||||
|
while ((item = IMMEDIATE_QUEUE.poll()) != null) {
|
||||||
|
try {
|
||||||
|
boolean resolved = service.publishAcceptedNow(item);
|
||||||
|
if (resolved) PENDING_SINCE_MS.remove(idKey(item.dataItemId()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Turbo недоступен: не держим поток клиента и не молотим всю очередь одной и той же ошибкой.
|
||||||
|
// Все элементы уже надёжно лежат в БД с pending=TRUE; плановый цикл подберёт их после min-age.
|
||||||
|
log.warn("Immediate Turbo publish failed; pending blocks will be retried by the periodic cycle: {}", e.getMessage());
|
||||||
|
IMMEDIATE_QUEUE.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
IMMEDIATE_DRAIN_SCHEDULED.set(false);
|
||||||
|
if (!IMMEDIATE_QUEUE.isEmpty()) scheduleImmediateDrain();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void close() {
|
||||||
|
ArweavePublishSignal.clearListener();
|
||||||
|
IMMEDIATE_QUEUE.clear();
|
||||||
|
PENDING_SINCE_MS.clear();
|
||||||
|
IMMEDIATE_DRAIN_SCHEDULED.set(false);
|
||||||
|
ScheduledExecutorService e = executor;
|
||||||
|
executor = null;
|
||||||
|
service = null;
|
||||||
|
config = null;
|
||||||
|
STARTED.set(false);
|
||||||
|
if (e != null) e.shutdownNow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+51
-4
@@ -6,9 +6,12 @@ import shine.db.dao.BlocksDAO;
|
|||||||
import shine.db.dao.KeyRotationCandidateBlocksDAO;
|
import shine.db.dao.KeyRotationCandidateBlocksDAO;
|
||||||
import shine.db.entities.BlockEntry;
|
import shine.db.entities.BlockEntry;
|
||||||
import shine.db.entities.KeyRotationCandidateBlockEntry;
|
import shine.db.entities.KeyRotationCandidateBlockEntry;
|
||||||
|
import server.sync.ArweavePublishSignal;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/** Publishes locally-created signed user DataItems through the configured transport. */
|
/** Publishes locally-created signed user DataItems through the configured transport. */
|
||||||
public final class ArweaveBlockPublisherService {
|
public final class ArweaveBlockPublisherService {
|
||||||
@@ -26,7 +29,47 @@ public final class ArweaveBlockPublisherService {
|
|||||||
this.turboUploader = cfg.publishMode() == ArweaveBlocksConfig.PublishMode.TURBO ? new TurboDataItemUploader(cfg) : null;
|
this.turboUploader = cfg.publishMode() == ArweaveBlocksConfig.PublishMode.TURBO ? new TurboDataItemUploader(cfg) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Мгновенная попытка для только что принятого DataItem. Вызывается только из фонового executor-а:
|
||||||
|
* сетевой запрос AddBlock не ждёт результат Turbo. Если запись уже успел обработать другой цикл, это no-op.
|
||||||
|
* При ошибке pending-флаг в БД не меняется, поэтому обычный runCycle() повторит публикацию позже.
|
||||||
|
*/
|
||||||
|
public boolean publishAcceptedNow(ArweavePublishSignal.PendingRef pending) throws Exception {
|
||||||
|
if (cfg.publishMode() != ArweaveBlocksConfig.PublishMode.TURBO) return false;
|
||||||
|
byte[] id = pending.dataItemId();
|
||||||
|
if (pending.kind() == ArweavePublishSignal.Kind.KEY_ROTATION_CANDIDATE) {
|
||||||
|
KeyRotationCandidateBlockEntry entry = candidateBlocksDAO.getPendingArweaveByDataItemId(id);
|
||||||
|
if (entry == null) return true;
|
||||||
|
byte[] raw = entry.getBlockBytes();
|
||||||
|
if (raw == null || raw.length == 0) return false;
|
||||||
|
TurboDataItemUploader.UploadResult result = turboUploader.upload(raw, id);
|
||||||
|
candidateBlocksDAO.markArweavePublished(List.of(id), System.currentTimeMillis());
|
||||||
|
log.debug("Turbo immediately published key-rotation DataItem {} chain={} block={}",
|
||||||
|
result.dataItemId(), entry.getCandidateBlockchainName(), entry.getBlockNumber());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockEntry entry = blocksDAO.getPendingArweaveByDataItemId(id);
|
||||||
|
if (entry == null) return true;
|
||||||
|
byte[] raw = entry.getBlockBytes();
|
||||||
|
if (raw == null || raw.length == 0) return false;
|
||||||
|
TurboDataItemUploader.UploadResult result = turboUploader.upload(raw, id);
|
||||||
|
blocksDAO.markArweavePublished(List.of(id), System.currentTimeMillis());
|
||||||
|
log.debug("Turbo immediately published SHiNE DataItem {} chain={} block={}",
|
||||||
|
result.dataItemId(), entry.getBchName(), entry.getBlockNumber());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public int runCycle() throws Exception {
|
public int runCycle() throws Exception {
|
||||||
|
return runCycle(id -> true, id -> {});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Плановый retry может отфильтровать слишком свежие pending-записи и получить callback успешных id. */
|
||||||
|
public int runRetryCycle(Predicate<byte[]> eligible, Consumer<byte[]> onPublished) throws Exception {
|
||||||
|
return runCycle(eligible == null ? id -> true : eligible, onPublished == null ? id -> {} : onPublished);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int runCycle(Predicate<byte[]> eligible, Consumer<byte[]> onPublished) throws Exception {
|
||||||
if (cfg.publishMode() == ArweaveBlocksConfig.PublishMode.NONE) return 0;
|
if (cfg.publishMode() == ArweaveBlocksConfig.PublishMode.NONE) return 0;
|
||||||
|
|
||||||
int maxItems = cfg.publishMaxItems();
|
int maxItems = cfg.publishMaxItems();
|
||||||
@@ -35,10 +78,11 @@ public final class ArweaveBlockPublisherService {
|
|||||||
|
|
||||||
// Ротация приоритетна: пользователь уже заблокирован для обычной записи и ждёт завершения копирования.
|
// Ротация приоритетна: пользователь уже заблокирован для обычной записи и ждёт завершения копирования.
|
||||||
List<KeyRotationCandidateBlockEntry> rotationCandidates = candidateBlocksDAO.listPendingArweave(maxItems);
|
List<KeyRotationCandidateBlockEntry> rotationCandidates = candidateBlocksDAO.listPendingArweave(maxItems);
|
||||||
|
rotationCandidates = rotationCandidates.stream().filter(e -> eligible.test(e.getDataItemId())).toList();
|
||||||
if (!rotationCandidates.isEmpty()) {
|
if (!rotationCandidates.isEmpty()) {
|
||||||
attempted += rotationCandidates.size();
|
attempted += rotationCandidates.size();
|
||||||
published += switch (cfg.publishMode()) {
|
published += switch (cfg.publishMode()) {
|
||||||
case TURBO -> publishTurboRotation(rotationCandidates);
|
case TURBO -> publishTurboRotation(rotationCandidates, onPublished);
|
||||||
case ARWEAVE -> publishDirectArweaveRotation(rotationCandidates);
|
case ARWEAVE -> publishDirectArweaveRotation(rotationCandidates);
|
||||||
case NONE -> 0;
|
case NONE -> 0;
|
||||||
};
|
};
|
||||||
@@ -48,16 +92,17 @@ public final class ArweaveBlockPublisherService {
|
|||||||
if (remaining == 0) return published;
|
if (remaining == 0) return published;
|
||||||
|
|
||||||
List<BlockEntry> candidates = blocksDAO.listPendingArweave(remaining);
|
List<BlockEntry> candidates = blocksDAO.listPendingArweave(remaining);
|
||||||
|
candidates = candidates.stream().filter(e -> eligible.test(e.getDataItemId())).toList();
|
||||||
if (candidates.isEmpty()) return published;
|
if (candidates.isEmpty()) return published;
|
||||||
published += switch (cfg.publishMode()) {
|
published += switch (cfg.publishMode()) {
|
||||||
case TURBO -> publishTurbo(candidates);
|
case TURBO -> publishTurbo(candidates, onPublished);
|
||||||
case ARWEAVE -> publishDirectArweave(candidates);
|
case ARWEAVE -> publishDirectArweave(candidates);
|
||||||
case NONE -> 0;
|
case NONE -> 0;
|
||||||
};
|
};
|
||||||
return published;
|
return published;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int publishTurboRotation(List<KeyRotationCandidateBlockEntry> candidates) throws Exception {
|
private int publishTurboRotation(List<KeyRotationCandidateBlockEntry> candidates, Consumer<byte[]> onPublished) throws Exception {
|
||||||
int published = 0;
|
int published = 0;
|
||||||
Exception firstFailure = null;
|
Exception firstFailure = null;
|
||||||
for (KeyRotationCandidateBlockEntry e : candidates) {
|
for (KeyRotationCandidateBlockEntry e : candidates) {
|
||||||
@@ -67,6 +112,7 @@ public final class ArweaveBlockPublisherService {
|
|||||||
try {
|
try {
|
||||||
TurboDataItemUploader.UploadResult result = turboUploader.upload(raw, id);
|
TurboDataItemUploader.UploadResult result = turboUploader.upload(raw, id);
|
||||||
candidateBlocksDAO.markArweavePublished(List.of(id), System.currentTimeMillis());
|
candidateBlocksDAO.markArweavePublished(List.of(id), System.currentTimeMillis());
|
||||||
|
onPublished.accept(id);
|
||||||
published++;
|
published++;
|
||||||
log.debug("Turbo published key-rotation DataItem {} chain={} block={}",
|
log.debug("Turbo published key-rotation DataItem {} chain={} block={}",
|
||||||
result.dataItemId(), e.getCandidateBlockchainName(), e.getBlockNumber());
|
result.dataItemId(), e.getCandidateBlockchainName(), e.getBlockNumber());
|
||||||
@@ -81,7 +127,7 @@ public final class ArweaveBlockPublisherService {
|
|||||||
return published;
|
return published;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int publishTurbo(List<BlockEntry> candidates) throws Exception {
|
private int publishTurbo(List<BlockEntry> candidates, Consumer<byte[]> onPublished) throws Exception {
|
||||||
int published = 0;
|
int published = 0;
|
||||||
Exception firstFailure = null;
|
Exception firstFailure = null;
|
||||||
for (BlockEntry e : candidates) {
|
for (BlockEntry e : candidates) {
|
||||||
@@ -91,6 +137,7 @@ public final class ArweaveBlockPublisherService {
|
|||||||
try {
|
try {
|
||||||
TurboDataItemUploader.UploadResult result = turboUploader.upload(raw, id);
|
TurboDataItemUploader.UploadResult result = turboUploader.upload(raw, id);
|
||||||
blocksDAO.markArweavePublished(List.of(id), System.currentTimeMillis());
|
blocksDAO.markArweavePublished(List.of(id), System.currentTimeMillis());
|
||||||
|
onPublished.accept(id);
|
||||||
published++;
|
published++;
|
||||||
log.debug("Turbo published SHiNE DataItem {} chain={} block={}", result.dataItemId(), e.getBchName(), e.getBlockNumber());
|
log.debug("Turbo published SHiNE DataItem {} chain={} block={}", result.dataItemId(), e.getBchName(), e.getBlockNumber());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|||||||
@@ -68,6 +68,16 @@ public final class BlocksDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Возвращает ещё не опубликованный пользовательский DataItem для быстрой Turbo-попытки. */
|
||||||
|
public BlockEntry getPendingArweaveByDataItemId(byte[] dataItemId) throws SQLException {
|
||||||
|
if (dataItemId == null || dataItemId.length != 32) return null;
|
||||||
|
String sql = baseSelect() + " WHERE data_item_id=? AND arweave_publish_pending=TRUE LIMIT 1";
|
||||||
|
try (Connection c = db.getConnection(); PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
|
ps.setBytes(1, dataItemId);
|
||||||
|
try (ResultSet rs = ps.executeQuery()) { return rs.next() ? mapRow(rs) : null; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<BlockEntry> listPendingArweave(int limit) throws SQLException {
|
public List<BlockEntry> listPendingArweave(int limit) throws SQLException {
|
||||||
int safeLimit = Math.max(1, Math.min(limit, 100_000));
|
int safeLimit = Math.max(1, Math.min(limit, 100_000));
|
||||||
String sql = """
|
String sql = """
|
||||||
|
|||||||
+14
@@ -132,6 +132,20 @@ public final class KeyRotationCandidateBlocksDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Возвращает ещё не опубликованный candidate DataItem для быстрой Turbo-попытки. */
|
||||||
|
public KeyRotationCandidateBlockEntry getPendingArweaveByDataItemId(byte[] dataItemId) throws SQLException {
|
||||||
|
if (dataItemId == null || dataItemId.length != 32) return null;
|
||||||
|
try (Connection c = db.getConnection();
|
||||||
|
PreparedStatement ps = c.prepareStatement("""
|
||||||
|
SELECT * FROM key_rotation_candidate_blocks
|
||||||
|
WHERE data_item_id = ? AND arweave_publish_pending = TRUE
|
||||||
|
LIMIT 1
|
||||||
|
""")) {
|
||||||
|
ps.setBytes(1, dataItemId);
|
||||||
|
try (ResultSet rs = ps.executeQuery()) { return rs.next() ? map(rs) : null; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Candidate-блоки имеют приоритет перед обычной очередью publisher-а. */
|
/** Candidate-блоки имеют приоритет перед обычной очередью publisher-а. */
|
||||||
public List<KeyRotationCandidateBlockEntry> listPendingArweave(int limit) throws SQLException {
|
public List<KeyRotationCandidateBlockEntry> listPendingArweave(int limit) throws SQLException {
|
||||||
if (limit <= 0) return List.of();
|
if (limit <= 0) return List.of();
|
||||||
|
|||||||
+6
@@ -32,6 +32,7 @@ import server.logic.ws_protocol.JSON.handlers.channels.ChannelNamesStateBootstra
|
|||||||
import server.logic.ws_protocol.JSON.handlers.channels.UserCountersSupport;
|
import server.logic.ws_protocol.JSON.handlers.channels.UserCountersSupport;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import server.sync.AddBlockSyncService;
|
import server.sync.AddBlockSyncService;
|
||||||
|
import server.sync.ArweavePublishSignal;
|
||||||
import shine.db.channels.ChannelNameRules;
|
import shine.db.channels.ChannelNameRules;
|
||||||
import shine.db.dao.BlockchainStateDAO;
|
import shine.db.dao.BlockchainStateDAO;
|
||||||
import shine.db.dao.BlocksDAO;
|
import shine.db.dao.BlocksDAO;
|
||||||
@@ -720,6 +721,11 @@ public final class Net_AddBlock_Handler implements JsonMessageHandler {
|
|||||||
upsertChat200StateFromCreate(chat200CreateSeed);
|
upsertChat200StateFromCreate(chat200CreateSeed);
|
||||||
}
|
}
|
||||||
maybeApplyChat200Command(blockchainName, block);
|
maybeApplyChat200Command(blockchainName, block);
|
||||||
|
|
||||||
|
if (publishToArweave) {
|
||||||
|
// Только ставим быструю публикацию в очередь: ответ клиенту не ждёт сеть Turbo/Arweave.
|
||||||
|
ArweavePublishSignal.userBlockAccepted(be.getDataItemId());
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (isChannelSlugConflict(e)) {
|
if (isChannelSlugConflict(e)) {
|
||||||
return new AddBlockResult(409, "channel_name_already_exists", serverLastNum, serverLastHashHex);
|
return new AddBlockResult(409, "channel_name_already_exists", serverLastNum, serverLastHashHex);
|
||||||
|
|||||||
+5
@@ -13,6 +13,7 @@ import server.logic.ws_protocol.JSON.handlers.JsonMessageHandler;
|
|||||||
import server.logic.ws_protocol.JSON.handlers.blockchain.Net_AddBlock_Handler_utils.BlockchainLocks;
|
import server.logic.ws_protocol.JSON.handlers.blockchain.Net_AddBlock_Handler_utils.BlockchainLocks;
|
||||||
import server.logic.ws_protocol.JSON.handlers.keyRotation.entyties.Net_KeyRotationAddBlock_Request;
|
import server.logic.ws_protocol.JSON.handlers.keyRotation.entyties.Net_KeyRotationAddBlock_Request;
|
||||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||||
|
import server.sync.ArweavePublishSignal;
|
||||||
import shine.db.DbController;
|
import shine.db.DbController;
|
||||||
import shine.db.dao.BlocksDAO;
|
import shine.db.dao.BlocksDAO;
|
||||||
import shine.db.dao.KeyRotationCandidateBlocksDAO;
|
import shine.db.dao.KeyRotationCandidateBlocksDAO;
|
||||||
@@ -164,6 +165,10 @@ public final class Net_KeyRotationAddBlock_Handler implements JsonMessageHandler
|
|||||||
c.setAutoCommit(oldAutoCommit);
|
c.setAutoCommit(oldAutoCommit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Как и обычный пользовательский блок, candidate сразу ставится в неблокирующую Turbo-очередь.
|
||||||
|
// При сетевой ошибке pending-флаг остаётся TRUE и его подберёт плановый retry.
|
||||||
|
ArweavePublishSignal.keyRotationCandidateAccepted(entry.getDataItemId());
|
||||||
|
|
||||||
// progressCurrent обновляет Arweave publisher только после реальной публикации.
|
// progressCurrent обновляет Arweave publisher только после реальной публикации.
|
||||||
KeyRotationSessionEntry refreshed = rotations.getActiveByLogin(login);
|
KeyRotationSessionEntry refreshed = rotations.getActiveByLogin(login);
|
||||||
return KeyRotationApiSupport.response(req.getOp(), req.getRequestId(), refreshed == null ? session : refreshed);
|
return KeyRotationApiSupport.response(req.getOp(), req.getRequestId(), refreshed == null ? session : refreshed);
|
||||||
|
|||||||
+74
@@ -0,0 +1,74 @@
|
|||||||
|
package server.sync;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Неблокирующий мост между приёмом блока по протоколу и Arweave/Turbo publisher-ом.
|
||||||
|
*
|
||||||
|
* Net-protocol не зависит от archive-модуля, поэтому publisher регистрирует здесь лёгкий listener.
|
||||||
|
* Listener обязан только поставить ссылку на уже сохранённый DataItem в свою очередь и не выполнять
|
||||||
|
* сетевую публикацию в потоке клиента.
|
||||||
|
*/
|
||||||
|
public final class ArweavePublishSignal {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ArweavePublishSignal.class);
|
||||||
|
|
||||||
|
public enum Kind {
|
||||||
|
USER_BLOCK,
|
||||||
|
KEY_ROTATION_CANDIDATE
|
||||||
|
}
|
||||||
|
|
||||||
|
public record PendingRef(Kind kind, byte[] dataItemId) {
|
||||||
|
public PendingRef {
|
||||||
|
if (kind == null) throw new IllegalArgumentException("kind is null");
|
||||||
|
if (dataItemId == null || dataItemId.length != 32) {
|
||||||
|
throw new IllegalArgumentException("dataItemId must be 32 bytes");
|
||||||
|
}
|
||||||
|
dataItemId = Arrays.copyOf(dataItemId, dataItemId.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] dataItemId() {
|
||||||
|
return Arrays.copyOf(dataItemId, dataItemId.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Listener {
|
||||||
|
void onPending(PendingRef item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static volatile Listener listener;
|
||||||
|
|
||||||
|
private ArweavePublishSignal() {}
|
||||||
|
|
||||||
|
public static void setListener(Listener value) {
|
||||||
|
listener = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearListener() {
|
||||||
|
listener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void userBlockAccepted(byte[] dataItemId) {
|
||||||
|
publish(new PendingRef(Kind.USER_BLOCK, dataItemId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void keyRotationCandidateAccepted(byte[] dataItemId) {
|
||||||
|
publish(new PendingRef(Kind.KEY_ROTATION_CANDIDATE, dataItemId));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void publish(PendingRef item) {
|
||||||
|
Listener current = listener;
|
||||||
|
if (current == null) return;
|
||||||
|
try {
|
||||||
|
current.onPending(item);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// Ошибка постановки в быструю очередь не должна превращать уже принятый блок в ошибку клиента:
|
||||||
|
// arweave_publish_pending остаётся TRUE, и плановый retry подберёт его позже.
|
||||||
|
log.warn("Cannot enqueue immediate Arweave/Turbo publish; periodic retry will keep the block pending", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
client.version=1.14.7
|
client.version=1.14.8
|
||||||
server.version=1.12.5
|
server.version=1.12.6
|
||||||
|
|||||||
@@ -12,13 +12,27 @@ export function escapeProfileHtml(text) {
|
|||||||
|
|
||||||
const esc = escapeProfileHtml;
|
const esc = escapeProfileHtml;
|
||||||
|
|
||||||
function statusChip({ kind, label, value, active }) {
|
function statusCardHtml({ kind, title, received, given }) {
|
||||||
const n = Number(value || 0);
|
const receivedCount = Number(received || 0);
|
||||||
|
const givenCount = Number(given || 0);
|
||||||
|
const isOfficial = kind === 'primary';
|
||||||
|
const receivedKind = isOfficial ? 'primary_received' : 'shine_received';
|
||||||
|
const givenKind = isOfficial ? 'primary_given' : 'shine_given';
|
||||||
|
const receivedTitle = isOfficial ? 'Кто подтвердил этот официальный аккаунт' : 'Кто подтвердил, что этот аккаунт сияющий';
|
||||||
|
const givenTitle = isOfficial ? 'Какие официальные аккаунты подтвердил этот пользователь' : 'Кого этот пользователь подтвердил как сияющего';
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<button type="button" class="pf-status${active ? ' is-active' : ''}" data-profile-list="${esc(kind)}"
|
<section class="pf-status-card pf-status-card--${esc(kind)}" aria-label="${esc(title)}">
|
||||||
aria-label="${esc(label)}: подтверждений ${n}" title="Статус «${esc(label)}». Число – сколько людей его подтвердили. Нажмите, чтобы увидеть кто.">
|
<div class="pf-status-card-title">${esc(title)}</div>
|
||||||
<span class="pf-status-dot" aria-hidden="true"></span>${esc(label)}${n > 0 ? `<b>${n}</b>` : ''}
|
<button type="button" class="pf-status-card-count" data-profile-list="${receivedKind}"
|
||||||
</button>`;
|
aria-label="${esc(receivedTitle)}: ${receivedCount}" title="${esc(receivedTitle)}">
|
||||||
|
<strong>${receivedCount}</strong><span>подтвердили</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="pf-status-card-count" data-profile-list="${givenKind}"
|
||||||
|
aria-label="${esc(givenTitle)}: ${givenCount}" title="${esc(givenTitle)}">
|
||||||
|
<strong>${givenCount}</strong><span>подтвердил</span>
|
||||||
|
</button>
|
||||||
|
</section>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function statHtml({ kind, label, valueHtml, ariaLabel }) {
|
function statHtml({ kind, label, valueHtml, ariaLabel }) {
|
||||||
@@ -75,19 +89,34 @@ export function profileCardHtml({ card, login = '', tilesHtml = '', tilesWrapCla
|
|||||||
const listInner = aboutRow + contacts + pathRow;
|
const listInner = aboutRow + contacts + pathRow;
|
||||||
const listHtml = listInner.trim() ? `<div class="pf-list">${listInner}</div>` : '';
|
const listHtml = listInner.trim() ? `<div class="pf-list">${listInner}</div>` : '';
|
||||||
const friends = Number(stats.friendsCount || 0);
|
const friends = Number(stats.friendsCount || 0);
|
||||||
const statusChips = [
|
|
||||||
(official || Number(stats.primaryReceivedCount || 0) > 0) && statusChip({ kind: 'primary_received', label: 'Официальный', value: stats.primaryReceivedCount, active: official }),
|
|
||||||
(shining || Number(stats.shineReceivedCount || 0) > 0) && statusChip({ kind: 'shine_received', label: 'Сияющий', value: stats.shineReceivedCount, active: shining }),
|
|
||||||
].filter(Boolean);
|
|
||||||
const statusesHtml = statusChips.length ? `<div class="pf-statuses">${statusChips.join('')}</div>` : '';
|
|
||||||
const closeFriends = Number(stats.closeFriendsCount || 0);
|
const closeFriends = Number(stats.closeFriendsCount || 0);
|
||||||
|
|
||||||
|
const officialCard = official
|
||||||
|
? statusCardHtml({
|
||||||
|
kind: 'primary',
|
||||||
|
title: 'Официальный',
|
||||||
|
received: stats.primaryReceivedCount,
|
||||||
|
given: stats.primaryGivenCount,
|
||||||
|
})
|
||||||
|
: '';
|
||||||
|
const shiningCard = shining
|
||||||
|
? statusCardHtml({
|
||||||
|
kind: 'shine',
|
||||||
|
title: 'Сияющий',
|
||||||
|
received: stats.shineReceivedCount,
|
||||||
|
given: stats.shineGivenCount,
|
||||||
|
})
|
||||||
|
: '';
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<div class="pf-hero${shining ? ' is-shining' : ''}" aria-label="Профиль ${esc(cardLogin)}">
|
<div class="pf-hero" aria-label="Профиль ${esc(cardLogin)}">
|
||||||
<div class="pf-avatar user-profile-avatar-slot"></div>
|
<div class="pf-identity">
|
||||||
|
<div class="pf-status-card-slot pf-status-card-slot--left">${officialCard}</div>
|
||||||
|
<div class="pf-avatar user-profile-avatar-slot"></div>
|
||||||
|
<div class="pf-status-card-slot pf-status-card-slot--right">${shiningCard}</div>
|
||||||
|
</div>
|
||||||
<h2 class="pf-name">${esc(displayName)}</h2>
|
<h2 class="pf-name">${esc(displayName)}</h2>
|
||||||
<div class="pf-login">@${esc(cardLogin)}</div>
|
<div class="pf-login">@${esc(cardLogin)}</div>
|
||||||
${statusesHtml}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pf-stats">
|
<div class="pf-stats">
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ export function render({ navigate, chrome }) {
|
|||||||
|
|
||||||
function renderProfile() {
|
function renderProfile() {
|
||||||
if (!card) return;
|
if (!card) return;
|
||||||
const official = card.accountRole === 'primary';
|
|
||||||
const shining = card.shineStatus === 'shining';
|
|
||||||
body.innerHTML = profileCardHtml({
|
body.innerHTML = profileCardHtml({
|
||||||
card,
|
card,
|
||||||
login,
|
login,
|
||||||
@@ -42,8 +40,6 @@ export function render({ navigate, chrome }) {
|
|||||||
].join(''),
|
].join(''),
|
||||||
}) + `
|
}) + `
|
||||||
<div class="nav-list profile-more-list">
|
<div class="nav-list profile-more-list">
|
||||||
<button class="nav-row" type="button" data-profile-list="primary_given"><span class="nav-row__label">Подтверждённые мной аккаунты</span><span class="nav-row__hint">Аккаунты, за которые вы поручились</span></button>
|
|
||||||
<button class="nav-row" type="button" data-profile-list="shine_given"><span class="nav-row__label">Отмеченные мной как сияющие</span></button>
|
|
||||||
<button class="nav-row" type="button" data-self-profile-action="profiles"><span class="nav-row__label">Сменить профиль</span><span class="nav-row__hint">Другие аккаунты на этом устройстве</span></button>
|
<button class="nav-row" type="button" data-self-profile-action="profiles"><span class="nav-row__label">Сменить профиль</span><span class="nav-row__hint">Другие аккаунты на этом устройстве</span></button>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
@@ -55,8 +51,6 @@ export function render({ navigate, chrome }) {
|
|||||||
avatar: card.avatar,
|
avatar: card.avatar,
|
||||||
size: 'xl',
|
size: 'xl',
|
||||||
className: 'user-profile-hero-avatar',
|
className: 'user-profile-hero-avatar',
|
||||||
glow: shining,
|
|
||||||
official,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
status.textContent = '';
|
status.textContent = '';
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { createTopBar } from '../components/topbar.js';
|
import { createTopBar } from '../components/topbar.js';
|
||||||
import { SHINE_CONNECTIONS_LOGO_SRC } from '../components/shine-logo.js';
|
import { SHINE_CONNECTIONS_LOGO_SRC } from '../components/shine-logo.js';
|
||||||
import { renderUserAvatar } from '../components/avatar-image.js';
|
import { renderUserAvatar } from '../components/avatar-image.js';
|
||||||
import { authService, state } from '../state.js';
|
import { state } from '../state.js';
|
||||||
import { loadRelationsForPair, loadUserProfileCard } from '../services/user-connections.js';
|
import { loadUserProfileCard } from '../services/user-connections.js';
|
||||||
import { makeProfileLinksRoute } from '../services/shine-routes.js';
|
import { makeProfileLinksRoute } from '../services/shine-routes.js';
|
||||||
import { navigateBack } from '../router.js';
|
import { navigateBack } from '../router.js';
|
||||||
import { profileCardHtml, profileTileHtml } from '../components/profile-card.js';
|
import { profileCardHtml, profileTileHtml } from '../components/profile-card.js';
|
||||||
@@ -18,27 +18,6 @@ function escapeHtml(text) {
|
|||||||
.replaceAll("'", ''');
|
.replaceAll("'", ''');
|
||||||
}
|
}
|
||||||
|
|
||||||
function effectiveSocial(flags = {}) {
|
|
||||||
if (flags.outCloseFriend) return 'close_friend';
|
|
||||||
if (flags.outFriend) return 'friend';
|
|
||||||
if (flags.outContact) return 'contact';
|
|
||||||
return 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
function relationMenuHtml(flags = {}) {
|
|
||||||
const current = effectiveSocial(flags);
|
|
||||||
const rows = [
|
|
||||||
['friend', 'Друг'],
|
|
||||||
['close_friend', 'Близкий друг'],
|
|
||||||
['contact', 'Контакт'],
|
|
||||||
];
|
|
||||||
return rows.map(([kind, label]) => `
|
|
||||||
<button type="button" class="user-profile-add-option${current === kind ? ' is-current' : ''}" data-relation-kind="${kind}">
|
|
||||||
<span>${escapeHtml(label)}</span>
|
|
||||||
<span class="user-profile-add-option-check" aria-hidden="true">${current === kind ? '✓' : ''}</span>
|
|
||||||
</button>`).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function render({ navigate, route, chrome }) {
|
export function render({ navigate, route, chrome }) {
|
||||||
const requestedLogin = String(route?.params?.login || '').trim();
|
const requestedLogin = String(route?.params?.login || '').trim();
|
||||||
const selfLogin = String(state.session.login || '').trim();
|
const selfLogin = String(state.session.login || '').trim();
|
||||||
@@ -61,80 +40,16 @@ export function render({ navigate, route, chrome }) {
|
|||||||
screen.append(status, body);
|
screen.append(status, body);
|
||||||
|
|
||||||
let card = null;
|
let card = null;
|
||||||
let relationFlags = null;
|
|
||||||
let relationLoadPromise = null;
|
|
||||||
let addMenu = null;
|
|
||||||
let addActionButton = null;
|
|
||||||
|
|
||||||
function updateRelationUi() {
|
|
||||||
if (!addMenu) return;
|
|
||||||
addMenu.innerHTML = relationMenuHtml(relationFlags || {});
|
|
||||||
const social = effectiveSocial(relationFlags || {});
|
|
||||||
addActionButton?.classList.toggle('is-active', social !== 'none');
|
|
||||||
addActionButton?.setAttribute('aria-label', social === 'none' ? 'Добавить' : 'Изменить связь');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function ensureRelationFlags() {
|
|
||||||
if (relationFlags) return relationFlags;
|
|
||||||
if (relationLoadPromise) return relationLoadPromise;
|
|
||||||
if (!selfLogin || !card?.login) return {};
|
|
||||||
relationLoadPromise = loadRelationsForPair({ currentLogin: selfLogin, targetLogin: card.login })
|
|
||||||
.then((flags) => {
|
|
||||||
relationFlags = flags || {};
|
|
||||||
updateRelationUi();
|
|
||||||
return relationFlags;
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
relationLoadPromise = null;
|
|
||||||
});
|
|
||||||
return relationLoadPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setRelationKind(kind, enabled) {
|
|
||||||
await authService.setUserRelation({
|
|
||||||
login: selfLogin,
|
|
||||||
toLogin: card.login,
|
|
||||||
kind,
|
|
||||||
enabled,
|
|
||||||
storagePwd: state.session.storagePwdInMemory,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function changeSocial(next) {
|
|
||||||
const flags = await ensureRelationFlags();
|
|
||||||
const current = effectiveSocial(flags);
|
|
||||||
if (current === next) return;
|
|
||||||
|
|
||||||
if (next === 'contact') {
|
|
||||||
if (flags.outCloseFriend) await setRelationKind('close_friend', false);
|
|
||||||
if (flags.outFriend) await setRelationKind('friend', false);
|
|
||||||
if (!flags.outContact) await setRelationKind('contact', true);
|
|
||||||
}
|
|
||||||
if (next === 'friend') {
|
|
||||||
if (flags.outCloseFriend) await setRelationKind('close_friend', false);
|
|
||||||
if (!flags.outFriend) await setRelationKind('friend', true);
|
|
||||||
}
|
|
||||||
if (next === 'close_friend' && !flags.outCloseFriend) {
|
|
||||||
await setRelationKind('close_friend', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
relationFlags = await loadRelationsForPair({ currentLogin: selfLogin, targetLogin: card.login });
|
|
||||||
updateRelationUi();
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderProfile() {
|
function renderProfile() {
|
||||||
if (!card) return;
|
if (!card) return;
|
||||||
const isSelf = card.login.toLowerCase() === selfLogin.toLowerCase();
|
const isSelf = card.login.toLowerCase() === selfLogin.toLowerCase();
|
||||||
const official = card.accountRole === 'primary';
|
|
||||||
const shining = card.shineStatus === 'shining';
|
|
||||||
|
|
||||||
body.innerHTML = profileCardHtml({
|
body.innerHTML = profileCardHtml({
|
||||||
card,
|
card,
|
||||||
login: requestedLogin,
|
login: requestedLogin,
|
||||||
isSelf,
|
isSelf,
|
||||||
beforeTilesHtml: '<div class="user-profile-add-menu" hidden></div>',
|
|
||||||
tilesHtml: isSelf ? '' : [
|
tilesHtml: isSelf ? '' : [
|
||||||
profileTileHtml({ icon: 'user-plus', label: 'Добавить', attrs: 'data-profile-action="add" aria-haspopup="menu" aria-expanded="false"' }),
|
profileTileHtml({ icon: 'user-plus', label: 'Добавить связь', attrs: 'data-profile-action="add"' }),
|
||||||
profileTileHtml({ label: 'Связи', attrs: 'data-profile-action="links"', iconMarkup: `<img class="pf-tile-mandala" src="${SHINE_CONNECTIONS_LOGO_SRC}" alt="" aria-hidden="true">` }),
|
profileTileHtml({ label: 'Связи', attrs: 'data-profile-action="links"', iconMarkup: `<img class="pf-tile-mandala" src="${SHINE_CONNECTIONS_LOGO_SRC}" alt="" aria-hidden="true">` }),
|
||||||
profileTileHtml({ icon: 'message', label: 'Написать', attrs: 'data-profile-action="chat"' }),
|
profileTileHtml({ icon: 'message', label: 'Написать', attrs: 'data-profile-action="chat"' }),
|
||||||
].join(''),
|
].join(''),
|
||||||
@@ -148,21 +63,12 @@ export function render({ navigate, route, chrome }) {
|
|||||||
avatar: card.avatar,
|
avatar: card.avatar,
|
||||||
size: 'xl',
|
size: 'xl',
|
||||||
className: 'user-profile-hero-avatar',
|
className: 'user-profile-hero-avatar',
|
||||||
glow: shining,
|
|
||||||
official,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
addMenu = body.querySelector('.user-profile-add-menu');
|
|
||||||
addActionButton = body.querySelector('[data-profile-action="add"]');
|
|
||||||
updateRelationUi();
|
|
||||||
status.textContent = '';
|
status.textContent = '';
|
||||||
|
|
||||||
if (!isSelf && selfLogin) {
|
|
||||||
void ensureRelationFlags().catch(() => {});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body.addEventListener('click', async (event) => {
|
body.addEventListener('click', (event) => {
|
||||||
if (!card) return;
|
if (!card) return;
|
||||||
const listButton = event.target.closest('[data-profile-list]');
|
const listButton = event.target.closest('[data-profile-list]');
|
||||||
if (listButton) {
|
if (listButton) {
|
||||||
@@ -171,34 +77,9 @@ export function render({ navigate, route, chrome }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const relationButton = event.target.closest('[data-relation-kind]');
|
|
||||||
if (relationButton) {
|
|
||||||
if (!selfLogin) {
|
|
||||||
status.className = 'status-line user-profile-status is-unavailable';
|
|
||||||
status.textContent = 'Для добавления пользователя необходимо войти.';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const next = relationButton.dataset.relationKind;
|
|
||||||
try {
|
|
||||||
addMenu?.classList.add('is-busy');
|
|
||||||
await changeSocial(next);
|
|
||||||
if (addMenu) addMenu.hidden = true;
|
|
||||||
addActionButton?.setAttribute('aria-expanded', 'false');
|
|
||||||
status.className = 'status-line user-profile-status';
|
|
||||||
status.textContent = '';
|
|
||||||
} catch (error) {
|
|
||||||
status.className = 'status-line user-profile-status is-unavailable';
|
|
||||||
status.textContent = `Ошибка: ${error?.message || 'Не удалось изменить связь'}`;
|
|
||||||
} finally {
|
|
||||||
addMenu?.classList.remove('is-busy');
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const actionButton = event.target.closest('[data-profile-action]');
|
const actionButton = event.target.closest('[data-profile-action]');
|
||||||
const action = actionButton?.dataset.profileAction;
|
const action = actionButton?.dataset.profileAction;
|
||||||
if (action === 'add') {
|
if (action === 'add') {
|
||||||
if (!addMenu) return;
|
|
||||||
navigate(`SHiNE/${encodeURIComponent(card.login)}/manage`);
|
navigate(`SHiNE/${encodeURIComponent(card.login)}/manage`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -211,17 +92,6 @@ export function render({ navigate, route, chrome }) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleOutsidePointer = (event) => {
|
|
||||||
if (!addMenu || addMenu.hidden) return;
|
|
||||||
if (event.target instanceof Node && body.contains(event.target)) {
|
|
||||||
const insideActions = event.target.closest?.('.user-profile-actions-wrap');
|
|
||||||
if (insideActions) return;
|
|
||||||
}
|
|
||||||
addMenu.hidden = true;
|
|
||||||
addActionButton?.setAttribute('aria-expanded', 'false');
|
|
||||||
};
|
|
||||||
document.addEventListener('pointerdown', handleOutsidePointer);
|
|
||||||
|
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
card = await loadUserProfileCard(requestedLogin);
|
card = await loadUserProfileCard(requestedLogin);
|
||||||
renderProfile();
|
renderProfile();
|
||||||
@@ -232,9 +102,5 @@ export function render({ navigate, route, chrome }) {
|
|||||||
status.textContent = `Ошибка: ${error?.message || 'unknown'}`;
|
status.textContent = `Ошибка: ${error?.message || 'unknown'}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
screen.cleanup = () => {
|
|
||||||
document.removeEventListener('pointerdown', handleOutsidePointer);
|
|
||||||
};
|
|
||||||
|
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,54 +2,231 @@ import { createTopBar } from '../components/topbar.js';
|
|||||||
import { authService, state } from '../state.js';
|
import { authService, state } from '../state.js';
|
||||||
import { loadRelationsForPair, loadUserProfileCard } from '../services/user-connections.js';
|
import { loadRelationsForPair, loadUserProfileCard } from '../services/user-connections.js';
|
||||||
import { navigateBack } from '../router.js';
|
import { navigateBack } from '../router.js';
|
||||||
|
import { escapeProfileHtml } from '../components/profile-card.js';
|
||||||
|
|
||||||
export const pageMeta = { id: 'user-relation-manage-view', title: 'Добавить' };
|
export const pageMeta = { id: 'user-relation-manage-view', title: 'Добавить связь' };
|
||||||
|
|
||||||
function effectiveSocial(f) { if (f.outCloseFriend) return 'close_friend'; if (f.outFriend) return 'friend'; if (f.outContact) return 'contact'; return 'none'; }
|
const SOCIAL_LABELS = {
|
||||||
|
none: 'Нет связи',
|
||||||
|
contact: 'Контакт',
|
||||||
|
friend: 'Друг',
|
||||||
|
close_friend: 'Близкий друг',
|
||||||
|
};
|
||||||
|
|
||||||
export function render({route, chrome}) {
|
const MUTUAL_LABELS = {
|
||||||
const targetLogin = String(route?.params?.login || '').trim(); const selfLogin = String(state.session.login || '').trim();
|
contact: 'контакты',
|
||||||
const screen = document.createElement('section'); screen.className = 'stack';
|
friend: 'друзья',
|
||||||
const body = document.createElement('div'); body.className = 'stack'; const status = document.createElement('div'); status.className = 'status-line';
|
close_friend: 'близкие друзья',
|
||||||
chrome?.setTopbar(createTopBar({ title: 'Добавить', back: { label: '←', onClick: () => navigateBack() } }));
|
};
|
||||||
screen.append(
|
|
||||||
status,
|
|
||||||
body,
|
|
||||||
);
|
|
||||||
let flags, selfCard, targetCard;
|
|
||||||
|
|
||||||
async function setKind(kind, enabled) { await authService.setUserRelation({ login: selfLogin, toLogin: targetLogin, kind, enabled, storagePwd: state.session.storagePwdInMemory }); }
|
function effectiveSocial(flags = {}, direction = 'out') {
|
||||||
async function changeSocial(next) {
|
const prefix = direction === 'in' ? 'in' : 'out';
|
||||||
const current = effectiveSocial(flags); if (current === next) return;
|
if (flags[`${prefix}CloseFriend`]) return 'close_friend';
|
||||||
if (next === 'none') { if (flags.outCloseFriend) await setKind('close_friend', false); if (flags.outFriend) await setKind('friend', false); if (flags.outContact) await setKind('contact', false); }
|
if (flags[`${prefix}Friend`]) return 'friend';
|
||||||
if (next === 'contact') { if (flags.outCloseFriend) await setKind('close_friend', false); if (flags.outFriend) await setKind('friend', false); if (!flags.outContact) await setKind('contact', true); }
|
if (flags[`${prefix}Contact`]) return 'contact';
|
||||||
if (next === 'friend') { if (flags.outCloseFriend) await setKind('close_friend', false); if (!flags.outFriend) await setKind('friend', true); }
|
return 'none';
|
||||||
if (next === 'close_friend' && !flags.outCloseFriend) await setKind('close_friend', true);
|
}
|
||||||
await refresh();
|
|
||||||
|
function relationSummaryHtml(flags = {}) {
|
||||||
|
const outgoing = effectiveSocial(flags, 'out');
|
||||||
|
const incoming = effectiveSocial(flags, 'in');
|
||||||
|
|
||||||
|
if (outgoing !== 'none' && outgoing === incoming) {
|
||||||
|
return `
|
||||||
|
<div class="relation-manage-mutual">
|
||||||
|
<span class="relation-manage-mutual-label">Взаимно:</span>
|
||||||
|
<strong>${escapeProfileHtml(MUTUAL_LABELS[outgoing])}</strong>
|
||||||
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refresh() {
|
return `
|
||||||
status.textContent = 'Загрузка...'; body.innerHTML = '';
|
<div class="relation-manage-current">
|
||||||
[selfCard, targetCard, flags] = await Promise.all([loadUserProfileCard(selfLogin), loadUserProfileCard(targetLogin), loadRelationsForPair({ currentLogin: selfLogin, targetLogin })]);
|
<div class="relation-manage-current-row">
|
||||||
const social = effectiveSocial(flags);
|
<span>Вы к пользователю</span>
|
||||||
const canPrimary = selfCard.accountRole === 'primary' && targetCard.accountRole !== 'non_voting';
|
<strong>${escapeProfileHtml(SOCIAL_LABELS[outgoing])}</strong>
|
||||||
const canShine = selfCard.accountRole === 'primary' && selfCard.shineStatus === 'shining' && targetCard.shineStatus !== 'not_interested';
|
|
||||||
body.innerHTML = `
|
|
||||||
<div class="card stack"><b>Связь с ${targetLogin}</b>
|
|
||||||
<div class="row wrap-row" data-social>${['none','contact','friend','close_friend'].map(v => `<button class="secondary-btn ${social===v?'is-active':''}" data-social-kind="${v}">${({none:'Нет',contact:'Контакт',friend:'Друг',close_friend:'Близкий друг'})[v]}</button>`).join('')}</div>
|
|
||||||
</div>
|
</div>
|
||||||
${canPrimary ? `<div class="card row"><span>Основной аккаунт</span><button class="secondary-btn" data-confirm="official_account">${flags.outOfficialAccount ? 'Убрать подтверждение' : 'Подтвердить'}</button></div>` : ''}
|
${incoming !== 'none' ? `
|
||||||
${canShine ? `<div class="card row"><span>Сияющий</span><button class="secondary-btn" data-confirm="shine_confirmed">${flags.outShineConfirmed ? 'Убрать подтверждение' : 'Подтвердить'}</button></div>` : ''}
|
<div class="relation-manage-current-row">
|
||||||
|
<span>Пользователь к вам</span>
|
||||||
|
<strong>${escapeProfileHtml(SOCIAL_LABELS[incoming])}</strong>
|
||||||
|
</div>` : ''}
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function socialButtonsHtml(flags = {}) {
|
||||||
|
const current = effectiveSocial(flags, 'out');
|
||||||
|
const kinds = ['none', 'contact', 'friend', 'close_friend'];
|
||||||
|
return kinds.map((kind) => `
|
||||||
|
<button type="button" class="secondary-btn relation-manage-choice${current === kind ? ' is-active' : ''}" data-social-kind="${kind}">
|
||||||
|
${escapeProfileHtml(SOCIAL_LABELS[kind])}
|
||||||
|
</button>`).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function officialBlockHtml(flags = {}) {
|
||||||
|
return `
|
||||||
|
<section class="card stack relation-manage-card relation-manage-card--official">
|
||||||
|
<div class="relation-manage-card-head">
|
||||||
|
<strong>Основной аккаунт</strong>
|
||||||
|
<span>Этот аккаунт — основной</span>
|
||||||
|
</div>
|
||||||
|
<div class="relation-manage-confirmations">
|
||||||
|
${flags.outOfficialAccount ? '<div class="relation-manage-confirmation">✓ Вы подтвердили его основной аккаунт</div>' : ''}
|
||||||
|
${flags.inOfficialAccount ? '<div class="relation-manage-confirmation">✓ Этот пользователь подтвердил ваш основной аккаунт</div>' : ''}
|
||||||
|
</div>
|
||||||
|
<button type="button" class="secondary-btn relation-manage-confirm-btn" data-confirm="official_account">
|
||||||
|
${flags.outOfficialAccount ? 'Убрать подтверждение' : 'Подтвердить основной аккаунт'}
|
||||||
|
</button>
|
||||||
|
</section>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function shineBlockHtml(flags = {}) {
|
||||||
|
return `
|
||||||
|
<section class="card stack relation-manage-card relation-manage-card--shine">
|
||||||
|
<div class="relation-manage-card-head">
|
||||||
|
<strong>Сияющий</strong>
|
||||||
|
<span>Этот аккаунт — сияющий</span>
|
||||||
|
</div>
|
||||||
|
<div class="relation-manage-confirmations">
|
||||||
|
${flags.outShineConfirmed ? '<div class="relation-manage-confirmation">✓ Вы подтверждаете его сияющим</div>' : ''}
|
||||||
|
${flags.inShineConfirmed ? '<div class="relation-manage-confirmation">✓ Этот пользователь подтверждает вас сияющим</div>' : ''}
|
||||||
|
</div>
|
||||||
|
<button type="button" class="secondary-btn relation-manage-confirm-btn" data-confirm="shine_confirmed">
|
||||||
|
${flags.outShineConfirmed ? 'Убрать подтверждение' : 'Подтвердить как сияющего'}
|
||||||
|
</button>
|
||||||
|
</section>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function render({ route, chrome }) {
|
||||||
|
const targetLogin = String(route?.params?.login || '').trim();
|
||||||
|
const selfLogin = String(state.session.login || '').trim();
|
||||||
|
const screen = document.createElement('section');
|
||||||
|
screen.className = 'stack relation-manage-screen';
|
||||||
|
|
||||||
|
const body = document.createElement('div');
|
||||||
|
body.className = 'stack relation-manage-body';
|
||||||
|
const status = document.createElement('div');
|
||||||
|
status.className = 'status-line relation-manage-status';
|
||||||
|
|
||||||
|
chrome?.setTopbar(createTopBar({
|
||||||
|
title: 'Добавить связь',
|
||||||
|
back: { label: '←', onClick: () => navigateBack() },
|
||||||
|
}));
|
||||||
|
screen.append(status, body);
|
||||||
|
|
||||||
|
let flags = {};
|
||||||
|
let selfCard = null;
|
||||||
|
let targetCard = null;
|
||||||
|
let busy = false;
|
||||||
|
|
||||||
|
async function setKind(kind, enabled) {
|
||||||
|
await authService.setUserRelation({
|
||||||
|
login: selfLogin,
|
||||||
|
toLogin: targetLogin,
|
||||||
|
kind,
|
||||||
|
enabled,
|
||||||
|
storagePwd: state.session.storagePwdInMemory,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function changeSocial(next) {
|
||||||
|
const current = effectiveSocial(flags, 'out');
|
||||||
|
if (current === next) return;
|
||||||
|
|
||||||
|
if (next === 'none') {
|
||||||
|
if (flags.outCloseFriend) await setKind('close_friend', false);
|
||||||
|
if (flags.outFriend) await setKind('friend', false);
|
||||||
|
if (flags.outContact) await setKind('contact', false);
|
||||||
|
}
|
||||||
|
if (next === 'contact') {
|
||||||
|
if (flags.outCloseFriend) await setKind('close_friend', false);
|
||||||
|
if (flags.outFriend) await setKind('friend', false);
|
||||||
|
if (!flags.outContact) await setKind('contact', true);
|
||||||
|
}
|
||||||
|
if (next === 'friend') {
|
||||||
|
if (flags.outCloseFriend) await setKind('close_friend', false);
|
||||||
|
if (!flags.outFriend) await setKind('friend', true);
|
||||||
|
}
|
||||||
|
if (next === 'close_friend' && !flags.outCloseFriend) {
|
||||||
|
await setKind('close_friend', true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderBody() {
|
||||||
|
const canPrimary = selfCard?.accountRole === 'primary' && targetCard?.accountRole === 'primary';
|
||||||
|
const canShine = selfCard?.shineStatus === 'shining' && targetCard?.shineStatus === 'shining';
|
||||||
|
|
||||||
|
body.innerHTML = `
|
||||||
|
<section class="card stack relation-manage-card relation-manage-card--social">
|
||||||
|
<div class="relation-manage-card-head">
|
||||||
|
<strong>Связь</strong>
|
||||||
|
<span>@${escapeProfileHtml(targetCard?.login || targetLogin)}</span>
|
||||||
|
</div>
|
||||||
|
${relationSummaryHtml(flags)}
|
||||||
|
<div class="relation-manage-choices" aria-label="Изменить ваше отношение к пользователю">
|
||||||
|
${socialButtonsHtml(flags)}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
${canPrimary ? officialBlockHtml(flags) : ''}
|
||||||
|
${canShine ? shineBlockHtml(flags) : ''}
|
||||||
`;
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refresh({ loading = true } = {}) {
|
||||||
|
if (loading) {
|
||||||
|
status.className = 'status-line relation-manage-status';
|
||||||
|
status.textContent = 'Загрузка...';
|
||||||
|
}
|
||||||
|
[selfCard, targetCard, flags] = await Promise.all([
|
||||||
|
loadUserProfileCard(selfLogin),
|
||||||
|
loadUserProfileCard(targetLogin),
|
||||||
|
loadRelationsForPair({ currentLogin: selfLogin, targetLogin }),
|
||||||
|
]);
|
||||||
|
renderBody();
|
||||||
|
status.className = 'status-line relation-manage-status';
|
||||||
status.textContent = '';
|
status.textContent = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
body.addEventListener('click', async (e) => {
|
body.addEventListener('click', async (event) => {
|
||||||
const btn = e.target.closest('button'); if (!btn) return;
|
const button = event.target.closest('button');
|
||||||
const social = btn.dataset.socialKind; const confirm = btn.dataset.confirm;
|
if (!button || busy) return;
|
||||||
try { status.textContent = 'Сохранение...'; if (social) await changeSocial(social); else if (confirm) { const enabled = confirm === 'official_account' ? !flags.outOfficialAccount : !flags.outShineConfirmed; await setKind(confirm, enabled); await refresh(); } }
|
|
||||||
catch (err) { status.className='status-line is-unavailable'; status.textContent=`Ошибка: ${err.message || 'unknown'}`; }
|
const social = button.dataset.socialKind;
|
||||||
|
const confirm = button.dataset.confirm;
|
||||||
|
if (!social && !confirm) return;
|
||||||
|
|
||||||
|
busy = true;
|
||||||
|
body.classList.add('is-busy');
|
||||||
|
status.className = 'status-line relation-manage-status';
|
||||||
|
status.textContent = 'Сохранение...';
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (social) {
|
||||||
|
await changeSocial(social);
|
||||||
|
} else if (confirm === 'official_account') {
|
||||||
|
await setKind('official_account', !flags.outOfficialAccount);
|
||||||
|
} else if (confirm === 'shine_confirmed') {
|
||||||
|
await setKind('shine_confirmed', !flags.outShineConfirmed);
|
||||||
|
}
|
||||||
|
await refresh({ loading: false });
|
||||||
|
} catch (error) {
|
||||||
|
status.className = 'status-line relation-manage-status is-unavailable';
|
||||||
|
status.textContent = `Ошибка: ${error?.message || 'Не удалось изменить связь'}`;
|
||||||
|
} finally {
|
||||||
|
busy = false;
|
||||||
|
body.classList.remove('is-busy');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
refresh().catch(e => { status.className='status-line is-unavailable'; status.textContent=`Ошибка: ${e.message || 'unknown'}`; });
|
|
||||||
|
if (!selfLogin || !targetLogin) {
|
||||||
|
status.className = 'status-line relation-manage-status is-unavailable';
|
||||||
|
status.textContent = 'Не удалось определить пользователя.';
|
||||||
|
return screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh().catch((error) => {
|
||||||
|
status.className = 'status-line relation-manage-status is-unavailable';
|
||||||
|
status.textContent = `Ошибка: ${error?.message || 'Не удалось загрузить связи'}`;
|
||||||
|
});
|
||||||
|
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,81 @@
|
|||||||
/* Карточка профиля (js/components/profile-card.js): свой и чужой профиль в одной системе с «О канале».
|
/* Карточка профиля (js/components/profile-card.js): свой и чужой профиль в одной системе с «О канале».
|
||||||
* Селекторы привязаны к .user-profile-screen, чтобы перекрыть старую геометрию profile.css. */
|
* Селекторы привязаны к .user-profile-screen, чтобы перекрыть старую геометрию profile.css. */
|
||||||
.user-profile-screen { gap: 0; min-height: 0; overflow-x: clip; } /* clip, а не hidden: hidden обрезал бы и свечение аватарки сверху */
|
.user-profile-screen { gap: 0; min-height: 0; overflow-x: clip; }
|
||||||
.user-profile-screen::before { content: none; }
|
.user-profile-screen::before { content: none; }
|
||||||
.user-profile-screen .user-profile-body { display: grid; gap: var(--space-4); padding: var(--space-2) 0 var(--space-5); }
|
.user-profile-screen .user-profile-body { display: grid; gap: var(--space-4); padding: var(--space-2) 0 var(--space-5); }
|
||||||
.user-profile-screen .user-profile-status:empty { display: none; }
|
.user-profile-screen .user-profile-status:empty { display: none; }
|
||||||
|
|
||||||
.user-profile-screen .pf-hero { display: grid; justify-items: center; gap: var(--space-1); text-align: center; }
|
.user-profile-screen .pf-hero { display: grid; justify-items: center; gap: var(--space-1); text-align: center; }
|
||||||
.user-profile-screen .pf-avatar { position: relative; grid-column: auto; grid-row: auto; width: 96px; height: 96px; margin-bottom: var(--space-2); display: grid; place-items: center; justify-self: center; }
|
.user-profile-screen .pf-identity {
|
||||||
|
width: min(100%, 420px);
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(72px, 1fr) 96px minmax(72px, 1fr);
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
.user-profile-screen .pf-status-card-slot { min-width: 0; display: grid; align-items: center; }
|
||||||
|
.user-profile-screen .pf-status-card-slot--left { justify-items: end; }
|
||||||
|
.user-profile-screen .pf-status-card-slot--right { justify-items: start; }
|
||||||
|
.user-profile-screen .pf-status-card {
|
||||||
|
width: min(100%, 106px);
|
||||||
|
aspect-ratio: 1;
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
|
||||||
|
border: 1px solid var(--border-subtle);
|
||||||
|
border-radius: var(--radius-lg);
|
||||||
|
background: var(--surface);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.user-profile-screen .pf-status-card--primary { border-color: color-mix(in srgb, var(--rel-family) 55%, var(--border-subtle)); }
|
||||||
|
.user-profile-screen .pf-status-card--shine { border-color: color-mix(in srgb, var(--rel-shining) 55%, var(--border-subtle)); }
|
||||||
|
.user-profile-screen .pf-status-card-title {
|
||||||
|
min-height: 27px;
|
||||||
|
padding: 7px 5px 5px;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.1;
|
||||||
|
font-weight: var(--weight-bold);
|
||||||
|
}
|
||||||
|
.user-profile-screen .pf-status-card-count {
|
||||||
|
min-width: 0;
|
||||||
|
padding: 3px 2px;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
align-content: center;
|
||||||
|
gap: 0;
|
||||||
|
border: 0;
|
||||||
|
border-top: 1px solid var(--border-subtle);
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.user-profile-screen .pf-status-card-count:hover,
|
||||||
|
.user-profile-screen .pf-status-card-count:active { background: var(--surface-selected); }
|
||||||
|
.user-profile-screen .pf-status-card-count:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
|
||||||
|
.user-profile-screen .pf-status-card-count strong { font-size: var(--text-md); line-height: 1.05; font-weight: var(--weight-bold); }
|
||||||
|
.user-profile-screen .pf-status-card-count span { color: var(--text-secondary); font-size: 9px; line-height: 1.05; }
|
||||||
|
.user-profile-screen .pf-avatar { position: relative; width: 96px; height: 96px; display: grid; place-items: center; justify-self: center; }
|
||||||
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar,
|
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar,
|
||||||
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-image { width: 96px; height: 96px; min-width: 96px; min-height: 96px; font-size: 36px; }
|
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-image { width: 96px; height: 96px; min-width: 96px; min-height: 96px; font-size: 36px; }
|
||||||
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-framed > .avatar-fallback,
|
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-framed > .avatar-fallback,
|
||||||
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-framed > .avatar-photo { width: 100%; height: 100%; }
|
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-framed > .avatar-photo { width: 100%; height: 100%; }
|
||||||
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-framed::after,
|
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-framed::after,
|
||||||
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-glow::before { content: none; }
|
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-glow::before { content: none; }
|
||||||
.user-profile-screen .pf-hero.is-shining .pf-avatar::after {
|
.user-profile-screen .pf-name { margin: var(--space-2) 0 0; color: var(--text-primary); font-size: var(--text-xl); line-height: var(--leading-xl); font-weight: var(--weight-bold); overflow-wrap: anywhere; }
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
inset: -5px;
|
|
||||||
border-radius: 50%;
|
|
||||||
border: 2px solid var(--rel-shining);
|
|
||||||
box-shadow: 0 0 14px var(--rel-shining-glow);
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
.user-profile-screen .pf-name { margin: 0; color: var(--text-primary); font-size: var(--text-xl); line-height: var(--leading-xl); font-weight: var(--weight-bold); overflow-wrap: anywhere; }
|
|
||||||
.user-profile-screen .pf-login { color: var(--text-secondary); font-size: var(--text-sm); line-height: var(--leading-sm); }
|
.user-profile-screen .pf-login { color: var(--text-secondary); font-size: var(--text-sm); line-height: var(--leading-sm); }
|
||||||
|
|
||||||
.user-profile-screen .pf-statuses { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-2); }
|
@media (max-width: 360px) {
|
||||||
.user-profile-screen .pf-status {
|
.user-profile-screen .pf-identity { grid-template-columns: minmax(66px, 1fr) 88px minmax(66px, 1fr); gap: 7px; }
|
||||||
min-height: 32px;
|
.user-profile-screen .pf-avatar,
|
||||||
padding: 0 12px;
|
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar,
|
||||||
display: inline-flex;
|
.user-profile-screen .pf-avatar .user-profile-hero-avatar.avatar-image { width: 88px; height: 88px; min-width: 88px; min-height: 88px; }
|
||||||
align-items: center;
|
.user-profile-screen .pf-status-card { width: min(100%, 96px); }
|
||||||
gap: 6px;
|
.user-profile-screen .pf-status-card-title { font-size: 10px; }
|
||||||
border: 1px solid var(--border-subtle);
|
.user-profile-screen .pf-status-card-count span { font-size: 8px; }
|
||||||
border-radius: var(--radius-pill);
|
|
||||||
color: var(--text-secondary);
|
|
||||||
background: var(--surface);
|
|
||||||
font: inherit;
|
|
||||||
font-size: var(--text-xs);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
.user-profile-screen .pf-status b { color: var(--text-primary); font-weight: var(--weight-bold); }
|
|
||||||
.user-profile-screen .pf-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-control); }
|
|
||||||
.user-profile-screen .pf-status.is-active { color: var(--text-primary); border-color: var(--border-control); }
|
|
||||||
.user-profile-screen .pf-status.is-active .pf-status-dot { background: var(--rel-shining); box-shadow: 0 0 6px var(--rel-shining-glow); }
|
|
||||||
.user-profile-screen .pf-status[data-profile-list='primary_received'].is-active .pf-status-dot { background: var(--rel-family); box-shadow: 0 0 6px var(--rel-family-glow); }
|
|
||||||
.user-profile-screen .pf-status:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
|
|
||||||
|
|
||||||
.user-profile-screen .pf-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
|
.user-profile-screen .pf-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
|
||||||
.user-profile-screen .pf-stat { min-height: 64px; padding: var(--space-2) var(--space-1); display: grid; align-content: center; justify-items: center; gap: 2px; border: 0; border-left: 1px solid var(--border-subtle); background: transparent; color: var(--text-primary); font: inherit; cursor: pointer; }
|
.user-profile-screen .pf-stat { min-height: 64px; padding: var(--space-2) var(--space-1); display: grid; align-content: center; justify-items: center; gap: 2px; border: 0; border-left: 1px solid var(--border-subtle); background: transparent; color: var(--text-primary); font: inherit; cursor: pointer; }
|
||||||
@@ -109,3 +139,35 @@
|
|||||||
.profiles-active-badge { padding: 2px 8px; border-radius: var(--radius-pill); color: var(--accent); background: var(--accent-soft); font-size: .6875rem; font-weight: var(--weight-bold); }
|
.profiles-active-badge { padding: 2px 8px; border-radius: var(--radius-pill); color: var(--accent); background: var(--accent-soft); font-size: .6875rem; font-weight: var(--weight-bold); }
|
||||||
.screen-content .profiles-row .profiles-close { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--radius-md); color: var(--text-secondary); background: transparent; font-size: 22px; cursor: pointer; }
|
.screen-content .profiles-row .profiles-close { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--radius-md); color: var(--text-secondary); background: transparent; font-size: 22px; cursor: pointer; }
|
||||||
.screen-content .profiles-row .profiles-close:hover { background: var(--surface-selected); color: var(--danger); }
|
.screen-content .profiles-row .profiles-close:hover { background: var(--surface-selected); color: var(--danger); }
|
||||||
|
|
||||||
|
/* Экран управления отношениями с другим пользователем. */
|
||||||
|
.relation-manage-screen { gap: var(--space-3); }
|
||||||
|
.relation-manage-status:empty { display: none; }
|
||||||
|
.relation-manage-body { gap: var(--space-3); }
|
||||||
|
.relation-manage-body.is-busy { opacity: .72; pointer-events: none; }
|
||||||
|
.relation-manage-card { gap: var(--space-3); }
|
||||||
|
.relation-manage-card-head { display: grid; gap: 2px; }
|
||||||
|
.relation-manage-card-head > strong { color: var(--text-primary); font-size: var(--text-md); }
|
||||||
|
.relation-manage-card-head > span { color: var(--text-secondary); font-size: var(--text-xs); }
|
||||||
|
.relation-manage-current { display: grid; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; }
|
||||||
|
.relation-manage-current-row { min-height: 48px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); border-top: 1px solid var(--border-subtle); }
|
||||||
|
.relation-manage-current-row:first-child { border-top: 0; }
|
||||||
|
.relation-manage-current-row > span { color: var(--text-secondary); font-size: var(--text-sm); }
|
||||||
|
.relation-manage-current-row > strong { color: var(--text-primary); font-size: var(--text-sm); text-align: right; }
|
||||||
|
.relation-manage-mutual { min-height: 52px; padding: 10px 12px; display: flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-selected); }
|
||||||
|
.relation-manage-mutual-label { color: var(--text-secondary); }
|
||||||
|
.relation-manage-mutual > strong { color: var(--text-primary); }
|
||||||
|
.relation-manage-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
|
||||||
|
.relation-manage-choice { width: 100%; min-width: 0; }
|
||||||
|
.relation-manage-choice.is-active { background: var(--surface-selected); border-color: var(--accent); color: var(--accent); }
|
||||||
|
.relation-manage-confirmations { display: grid; gap: 6px; }
|
||||||
|
.relation-manage-confirmations:empty { display: none; }
|
||||||
|
.relation-manage-confirmation { padding: 9px 11px; border-radius: var(--radius-md); background: var(--surface-selected); color: var(--text-primary); font-size: var(--text-sm); line-height: var(--leading-sm); }
|
||||||
|
.relation-manage-confirm-btn { width: 100%; }
|
||||||
|
.relation-manage-card--official { border-color: color-mix(in srgb, var(--rel-family) 45%, var(--border-subtle)); }
|
||||||
|
.relation-manage-card--shine { border-color: color-mix(in srgb, var(--rel-shining) 45%, var(--border-subtle)); }
|
||||||
|
|
||||||
|
@media (max-width: 420px) {
|
||||||
|
.relation-manage-choices { grid-template-columns: 1fr; }
|
||||||
|
.relation-manage-current-row { align-items: flex-start; }
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user