From d1b93eacaca7cf01df23da1abdf5fc445d240e6d Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Sat, 24 Jun 2023 11:58:31 +0000 Subject: [PATCH] rewrite application navigation handlers --- .../settings/components/sessions/index.jsx | 2 +- .../FeaturedEventAnnouncement/index.jsx | 2 +- packages/app/src/components/Footer/index.jsx | 2 +- .../src/components/Layout/sidebar/index.jsx | 4 +- .../app/src/components/Navigation/index.jsx | 2 +- .../components/Player/MediaPlayer/index.jsx | 2 +- .../PlaylistTimelineEntry/index.jsx | 2 +- .../app/src/components/PostCard/index.jsx | 2 +- .../app/src/components/RenderError/index.jsx | 2 +- .../src/components/WidgetsWrapper/index.jsx | 2 +- packages/app/src/pages/[param].jsx | 2 +- .../src/pages/home/components/feed/index.jsx | 2 +- packages/app/src/pages/lyrics/index.jsx | 2 +- .../components/dashboard/releases/index.jsx | 2 +- .../src/pages/music/components/feed/index.jsx | 2 +- .../components/TracksUploads/index.jsx | 2 +- packages/app/src/pages/tv/tabs/feed/index.jsx | 2 +- packages/app/src/router.jsx | 88 ++++++++++--------- packages/app/src/theme/fixments.less | 22 +++++ 19 files changed, 85 insertions(+), 61 deletions(-) diff --git a/packages/app/constants/settings/components/sessions/index.jsx b/packages/app/constants/settings/components/sessions/index.jsx index b187f994..54e20b4c 100755 --- a/packages/app/constants/settings/components/sessions/index.jsx +++ b/packages/app/constants/settings/components/sessions/index.jsx @@ -4,7 +4,7 @@ import { Button } from "antd" export default (props) => { return } + extra={} /> } } @@ -140,52 +140,54 @@ function generatePageElementWrapper(route, element, bindProps) { export const PageRender = React.memo((props) => { const navigate = useNavigate() - app.location = useLocation() - React.useEffect(() => { - app.setLocation = async (to, state = {}) => { - // clean double slashes - to = to.replace(/\/{2,}/g, "/") + async function setLocation(to, state = {}) { + // clean double slashes + to = to.replace(/\/{2,}/g, "/") - // if state is a number, it's a delay - if (typeof state !== "object") { - state = {} - } - - const transitionDuration = app.cores.style.getValue("page-transition-duration") ?? "250ms" - - state.transitionDelay = Number(transitionDuration.replace("ms", "")) - - app.eventBus.emit("router.navigate", to, { - state, - }) - - app.location.lastPathname = app.location.pathname - - if (state.transitionDelay >= 100) { - await new Promise((resolve) => { - setTimeout(() => { - resolve() - }, state.transitionDelay) - }) - } - - return navigate(to, { - state - }) + // if state is a number, it's a delay + if (typeof state !== "object") { + state = {} } - app.backLocation = (state = {}) => { - let to = app.location.lastPathname + const transitionDuration = app.cores.style.getValue("page-transition-duration") ?? "250ms" - if (!to || to === app.location.pathname) { - console.warn("No last location found, redirecting to /") - to = "/" - } + state.transitionDelay = Number(transitionDuration.replace("ms", "")) - return navigate(to, { - state - }) + app.eventBus.emit("router.navigate", to, { + state, + }) + + app.location.last = window.location + + if (state.transitionDelay >= 100) { + await new Promise((resolve) => setTimeout(resolve, state.transitionDelay)) + } + + return navigate(to, { + state + }) + } + + async function backLocation() { + const transitionDuration = app.cores.style.getValue("page-transition-duration") ?? "250ms" + + app.eventBus.emit("router.navigate") + + app.location.last = window.location + + if (transitionDuration >= 100) { + await new Promise((resolve) => setTimeout(resolve, transitionDuration)) + } + + return window.history.back() + } + + React.useEffect(() => { + app.location = { + last: window.location, + push: setLocation, + back: backLocation, } }, []) diff --git a/packages/app/src/theme/fixments.less b/packages/app/src/theme/fixments.less index 50a6dc0c..3bc35c20 100755 --- a/packages/app/src/theme/fixments.less +++ b/packages/app/src/theme/fixments.less @@ -529,4 +529,26 @@ } } } +} + +.adm-action-sheet { + .adm-action-sheet-button-item-wrapper { + border-bottom-color: var(--border-color); + + .adm-action-sheet-button-item { + .adm-action-sheet-button-item-name { + color: var(--text-color); + + span { + color: currentColor; + } + } + } + + .adm-action-sheet-button-item-danger { + .adm-action-sheet-button-item-name { + color: var(--adm-color-danger); + } + } + } } \ No newline at end of file