SHA256
UI: индикатор загрузки истории чата
This commit is contained in:
@@ -837,6 +837,16 @@ export function render({ navigate, route }) {
|
||||
const wrap = document.createElement('div');
|
||||
wrap.className = 'chat-wrap dm-chat-wrap';
|
||||
|
||||
const historyLoader = document.createElement('div');
|
||||
historyLoader.className = 'dm-history-loader';
|
||||
historyLoader.hidden = true;
|
||||
historyLoader.innerHTML = `
|
||||
<div class="dm-history-loader__pill" aria-live="polite" aria-busy="true">
|
||||
<span class="dm-history-loader__spinner" aria-hidden="true"></span>
|
||||
<span class="dm-history-loader__label">Загрузка истории…</span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const log = document.createElement('div');
|
||||
log.className = 'messages-log dm-messages-log';
|
||||
|
||||
@@ -987,6 +997,11 @@ export function render({ navigate, route }) {
|
||||
}
|
||||
};
|
||||
|
||||
const setHistoryLoadingState = (isLoading) => {
|
||||
historyLoader.hidden = !isLoading;
|
||||
historyLoader.classList.toggle('is-visible', !!isLoading);
|
||||
};
|
||||
|
||||
const syncComposerLayout = () => {
|
||||
const height = Number.parseFloat(input?.style.height || '0');
|
||||
form.classList.toggle('dm-chat-input--multiline', height > 52);
|
||||
@@ -1325,6 +1340,7 @@ export function render({ navigate, route }) {
|
||||
if (historyLoading) return;
|
||||
if (historyBootstrapped && !historyHasMore) return;
|
||||
historyLoading = true;
|
||||
setHistoryLoadingState(true);
|
||||
const scrollContainer = boundScrollContainer || log.closest('.screen-content') || wrap.parentElement || wrap;
|
||||
const prevScrollTop = Number(scrollContainer?.scrollTop || 0);
|
||||
const prevScrollHeight = Number(scrollContainer?.scrollHeight || 0);
|
||||
@@ -1359,6 +1375,7 @@ export function render({ navigate, route }) {
|
||||
});
|
||||
} finally {
|
||||
historyLoading = false;
|
||||
setHistoryLoadingState(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1467,7 +1484,7 @@ export function render({ navigate, route }) {
|
||||
window.visualViewport?.addEventListener('resize', syncKeyboardUi);
|
||||
window.addEventListener('resize', syncKeyboardUi);
|
||||
|
||||
wrap.append(log, form);
|
||||
wrap.append(historyLoader, log, form);
|
||||
screen.append(wrap);
|
||||
renderLog(log, chatId, {
|
||||
onOpenActions: handleOpenActions,
|
||||
|
||||
Reference in New Issue
Block a user