SHA256
Стрелка «назад» в каналах шагает по истории, а не по кругу
Ответ → запись → канал → список каналов: если на страницу пришли из канала или обсуждения, «назад» возвращает по истории. Раньше повторный переход гонял по кругу запись и открытый из неё ответ.
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
client.version=1.18.9
|
client.version=1.18.10
|
||||||
server.version=1.14.0
|
server.version=1.14.0
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@
|
|||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
window.__SHINE_BUILD_HASH__ = '20261012094800';
|
window.__SHINE_BUILD_HASH__ = '20261012121500';
|
||||||
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
|
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
showToast,
|
showToast,
|
||||||
softHaptic,
|
softHaptic,
|
||||||
} from '../services/channels-ux.js';
|
} from '../services/channels-ux.js';
|
||||||
import { getPreviousTrackedPath, parseRouteFromPath, toPrettyPath } from '../router.js';
|
import { navigateUp, parseRouteFromPath, toPrettyPath } from '../router.js';
|
||||||
import { renderAvatar, renderUserAvatar } from '../components/avatar-image.js';
|
import { renderAvatar, renderUserAvatar } from '../components/avatar-image.js';
|
||||||
import { openChannelEditor } from '../components/channel-editor.js';
|
import { openChannelEditor } from '../components/channel-editor.js';
|
||||||
import { createDropdownMenu } from '../components/dropdown-menu.js';
|
import { createDropdownMenu } from '../components/dropdown-menu.js';
|
||||||
@@ -370,19 +370,8 @@ function resolveThreadBackRoute(selector, resolvedChannelLabel = '') {
|
|||||||
return buildChannelRouteFromThread(selector, resolvedChannelLabel) || 'channels-list';
|
return buildChannelRouteFromThread(selector, resolvedChannelLabel) || 'channels-list';
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveThreadPreviousInChannels(selector, resolvedChannelLabel = '') {
|
function isChannelPage(route) {
|
||||||
const previousPath = String(getPreviousTrackedPath() || '').trim();
|
return route?.pageId === 'channel-thread-view' || route?.pageId === 'channel-view';
|
||||||
if (previousPath) {
|
|
||||||
const previousRoute = parseRouteFromPath(previousPath);
|
|
||||||
const previousPageId = String(previousRoute?.pageId || '').trim();
|
|
||||||
if (
|
|
||||||
previousPageId === 'channel-thread-view'
|
|
||||||
|| previousPageId === 'channel-view'
|
|
||||||
) {
|
|
||||||
return previousPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resolveThreadBackRoute(selector, resolvedChannelLabel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTargetFromNode(node) {
|
function buildTargetFromNode(node) {
|
||||||
@@ -1624,7 +1613,7 @@ export function render({ navigate, route, chrome }) {
|
|||||||
const header = createTopBar({
|
const header = createTopBar({
|
||||||
center: threadHeaderButton,
|
center: threadHeaderButton,
|
||||||
className: 'topbar--identity',
|
className: 'topbar--identity',
|
||||||
back: state.session.isAuthorized ? { label: '<', onClick: () => navigate(resolveThreadPreviousInChannels(selector, activeResolvedChannelLabel)) } : null,
|
back: state.session.isAuthorized ? { label: '<', onClick: () => navigateUp(isChannelPage, resolveThreadBackRoute(selector, activeResolvedChannelLabel)) } : null,
|
||||||
actions: [{
|
actions: [{
|
||||||
label: '⋯',
|
label: '⋯',
|
||||||
ariaLabel: 'Меню обсуждения',
|
ariaLabel: 'Меню обсуждения',
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { appendShineMessageLinks } from '../services/shine-message-links.js';
|
|||||||
import { confirmDialog } from '../components/confirm-dialog.js';
|
import { confirmDialog } from '../components/confirm-dialog.js';
|
||||||
import { iconHtml } from '../components/ui-icon.js';
|
import { iconHtml } from '../components/ui-icon.js';
|
||||||
import { rememberChannelPosition, readChannelPosition, requestReplyEditorOnOpen, restoreChannelPosition } from '../services/channel-view-state.js';
|
import { rememberChannelPosition, readChannelPosition, requestReplyEditorOnOpen, restoreChannelPosition } from '../services/channel-view-state.js';
|
||||||
import { getPreviousTrackedPath, parseRouteFromPath, toPrettyPath } from '../router.js';
|
import { getPreviousTrackedPath, navigateUp, parseRouteFromPath, toPrettyPath } from '../router.js';
|
||||||
import { prefetchThreadPage, threadTotalReplies } from './channel-thread-view.js';
|
import { prefetchThreadPage, threadTotalReplies } from './channel-thread-view.js';
|
||||||
import { attachMessageMenu } from '../components/message-menu.js';
|
import { attachMessageMenu } from '../components/message-menu.js';
|
||||||
import { createTopBar } from '../components/topbar.js';
|
import { createTopBar } from '../components/topbar.js';
|
||||||
@@ -2608,7 +2608,7 @@ export function render({ navigate, route, chrome }) {
|
|||||||
|
|
||||||
const header = createTopBar({
|
const header = createTopBar({
|
||||||
center: channelHeaderButton,
|
center: channelHeaderButton,
|
||||||
back: state.session.isAuthorized ? { onClick: () => navigate('channels-list') } : null,
|
back: state.session.isAuthorized ? { onClick: () => navigateUp((route) => route?.pageId === 'channels-list', 'channels-list') } : null,
|
||||||
className: 'channel-view-topbar topbar--identity',
|
className: 'channel-view-topbar topbar--identity',
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
|
|||||||
+16
-3
@@ -462,12 +462,14 @@ export function getRoute() {
|
|||||||
export function navigate(path) {
|
export function navigate(path) {
|
||||||
const cleanPath = toPrettyPath(path);
|
const cleanPath = toPrettyPath(path);
|
||||||
const nextPath = cleanPath ? `/${cleanPath}` : '/';
|
const nextPath = cleanPath ? `/${cleanPath}` : '/';
|
||||||
if (window.location.pathname !== nextPath) {
|
const fromPath = window.location.pathname;
|
||||||
|
if (fromPath !== nextPath) {
|
||||||
previousTrackedPath = currentTrackedPath;
|
previousTrackedPath = currentTrackedPath;
|
||||||
currentTrackedPath = nextPath;
|
currentTrackedPath = nextPath;
|
||||||
}
|
}
|
||||||
if (window.location.pathname !== nextPath) {
|
if (fromPath !== nextPath) {
|
||||||
window.history.pushState({}, '', nextPath);
|
// Запись помнит, откуда на неё пришли: «назад» в шапке может вернуться по истории, а не открывать страницу заново.
|
||||||
|
window.history.pushState({ shineFrom: fromPath }, '', nextPath);
|
||||||
}
|
}
|
||||||
window.dispatchEvent(new PopStateEvent('popstate'));
|
window.dispatchEvent(new PopStateEvent('popstate'));
|
||||||
}
|
}
|
||||||
@@ -517,6 +519,17 @@ export function toPrettyPath(path) {
|
|||||||
return [prettyHead, ...tail].join('/');
|
return [prettyHead, ...tail].join('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Стрелка «назад» в шапке: если сюда пришли со страницы, которую isParent признаёт своей, – шаг по истории
|
||||||
|
// (как стек: ответ → запись → канал), иначе переход на fallback. Повторный navigate гонял бы по кругу две страницы.
|
||||||
|
export function navigateUp(isParent, fallback) {
|
||||||
|
const from = String(window.history.state?.shineFrom || '');
|
||||||
|
if (from && isParent(parseRouteFromPath(from), from)) {
|
||||||
|
window.history.back();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
navigate(fallback);
|
||||||
|
}
|
||||||
|
|
||||||
export function navigateBack() {
|
export function navigateBack() {
|
||||||
if (window.history.length <= 1) return;
|
if (window.history.length <= 1) return;
|
||||||
window.history.back();
|
window.history.back();
|
||||||
|
|||||||
Reference in New Issue
Block a user