mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
web/mainscreen: add hack to skip transitions if browser provides them
This commit is contained in:
parent
5f880b2487
commit
7b7fbce4df
1 changed files with 8 additions and 2 deletions
|
@ -13,7 +13,7 @@
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import { JSX, use, useEffect, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useState } from "react"
|
import { JSX, use, useEffect, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react"
|
||||||
import { SyncLoader } from "react-spinners"
|
import { SyncLoader } from "react-spinners"
|
||||||
import Client from "@/api/client.ts"
|
import Client from "@/api/client.ts"
|
||||||
import { RoomStateStore } from "@/api/statestore"
|
import { RoomStateStore } from "@/api/statestore"
|
||||||
|
@ -221,7 +221,8 @@ const activeRoomReducer = (prev: ActiveRoomType, active: RoomStateStore | "clear
|
||||||
}
|
}
|
||||||
|
|
||||||
const MainScreen = () => {
|
const MainScreen = () => {
|
||||||
const [[prevActiveRoom, activeRoom], directSetActiveRoom] = useReducer(activeRoomReducer, [null, null] as const)
|
const [[prevActiveRoom, activeRoom], directSetActiveRoom] = useReducer(activeRoomReducer, [null, null])
|
||||||
|
const skipNextTransitionRef = useRef(false)
|
||||||
const [rightPanel, directSetRightPanel] = useState<RightPanelProps | null>(null)
|
const [rightPanel, directSetRightPanel] = useState<RightPanelProps | null>(null)
|
||||||
const client = use(ClientContext)!
|
const client = use(ClientContext)!
|
||||||
const syncStatus = useEventAsState(client.syncStatus)
|
const syncStatus = useEventAsState(client.syncStatus)
|
||||||
|
@ -234,6 +235,7 @@ const MainScreen = () => {
|
||||||
}, [context])
|
}, [context])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const listener = (evt: PopStateEvent) => {
|
const listener = (evt: PopStateEvent) => {
|
||||||
|
skipNextTransitionRef.current = evt.hasUAVisualTransition
|
||||||
const roomID = evt.state?.room_id ?? null
|
const roomID = evt.state?.room_id ?? null
|
||||||
if (roomID !== client.store.activeRoomID) {
|
if (roomID !== client.store.activeRoomID) {
|
||||||
context.setActiveRoom(roomID, false)
|
context.setActiveRoom(roomID, false)
|
||||||
|
@ -282,6 +284,10 @@ const MainScreen = () => {
|
||||||
["--room-list-width" as string]: `${roomListWidth}px`,
|
["--room-list-width" as string]: `${roomListWidth}px`,
|
||||||
["--right-panel-width" as string]: `${rightPanelWidth}px`,
|
["--right-panel-width" as string]: `${rightPanelWidth}px`,
|
||||||
}
|
}
|
||||||
|
if (skipNextTransitionRef.current) {
|
||||||
|
extraStyle["transition"] = "none"
|
||||||
|
skipNextTransitionRef.current = false
|
||||||
|
}
|
||||||
const classNames = ["matrix-main"]
|
const classNames = ["matrix-main"]
|
||||||
if (activeRoom) {
|
if (activeRoom) {
|
||||||
classNames.push("room-selected")
|
classNames.push("room-selected")
|
||||||
|
|
Loading…
Add table
Reference in a new issue