diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index e87c3fb..607cd90 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -68,6 +68,7 @@ export default defineComponent({ const store = useStore(), sidebar = ref(null), + firstLoad = computed(() => store.state.firstLoad), currentlyVisible = computed(() => store.state.ui.visibleElements), previouslyVisible = computed(() => store.state.ui.previouslyVisibleElements), smallScreen = computed(() => store.state.ui.smallScreen), @@ -119,8 +120,9 @@ export default defineComponent({ const focusMaps = () => focus('.section__heading button'); const focusPlayers = () => focus('#players-heading'); - watch(playersVisible, newValue => newValue && nextTick(() => focusPlayers())); - watch(mapsVisible, newValue => newValue && nextTick(() => focusMaps())); + //Focus sidebar sections when they become visible, except on initial load + watch(playersVisible, newValue => newValue && !firstLoad.value && nextTick(() => focusPlayers())); + watch(mapsVisible, newValue => newValue && !firstLoad.value && nextTick(() => focusMaps())); return { sidebar, diff --git a/src/store/actions.ts b/src/store/actions.ts index 89f2e57..08b98e6 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -25,6 +25,7 @@ import { DynmapTileUpdate, } from "@/dynmap"; import {LiveAtlasMarkerSet, LiveAtlasPlayer, LiveAtlasWorldDefinition} from "@/index"; +import {nextTick} from "vue"; type AugmentedActionContext = { commit( @@ -96,8 +97,8 @@ export const actions: ActionTree & Actions = { await state.currentMapProvider!.loadServerConfiguration(); - //Skip default map/ui visibility logic if we already have a map selected (i.e config reload after hash change) - if(state.currentMap) { + //Skip default map/ui visibility logic if not first load (i.e config reload after hash change) + if(!state.firstLoad) { return; } @@ -148,6 +149,8 @@ export const actions: ActionTree & Actions = { worldName, mapName }); } + + await nextTick(() => commit(MutationTypes.SET_LOADED, undefined)); }, async [ActionTypes.START_UPDATES]({state}) { diff --git a/src/store/mutation-types.ts b/src/store/mutation-types.ts index 17e6227..20abe38 100644 --- a/src/store/mutation-types.ts +++ b/src/store/mutation-types.ts @@ -36,6 +36,7 @@ export enum MutationTypes { SET_MAX_PLAYERS = 'setMaxPlayers', SET_PLAYERS_ASYNC = 'setPlayersAsync', SYNC_PLAYERS = 'syncPlayers', + SET_LOADED = 'setLoaded', SET_CURRENT_SERVER = 'setCurrentServer', SET_CURRENT_MAP = 'setCurrentMap', diff --git a/src/store/mutations.ts b/src/store/mutations.ts index d3fade8..f3bba26 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -30,7 +30,6 @@ import { LiveAtlasWorldDefinition, LiveAtlasParsedUrl, LiveAtlasGlobalConfig, - LiveAtlasGlobalMessageConfig, LiveAtlasServerMessageConfig, LiveAtlasPlayer, LiveAtlasCircleMarker, @@ -78,6 +77,7 @@ export type Mutations = { [MutationTypes.SET_MAX_PLAYERS](state: S, maxPlayers: number): void [MutationTypes.SET_PLAYERS_ASYNC](state: S, players: Set): Set [MutationTypes.SYNC_PLAYERS](state: S, keep: Set): void + [MutationTypes.SET_LOADED](state: S, a?: void): void [MutationTypes.SET_CURRENT_SERVER](state: S, server: string): void [MutationTypes.SET_CURRENT_MAP](state: S, payload: CurrentMapPayload): void [MutationTypes.SET_CURRENT_LOCATION](state: S, payload: Coordinate): void @@ -455,6 +455,11 @@ export const mutations: MutationTree & Mutations = { } }, + //Sets flag indicating LiveAtlas has fully loaded + [MutationTypes.SET_LOADED](state: State) { + state.firstLoad = false; + }, + //Sets the currently active server [MutationTypes.SET_CURRENT_SERVER](state: State, serverName) { if(!state.servers.has(serverName)) { diff --git a/src/store/state.ts b/src/store/state.ts index 3d6f889..a36a938 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -43,6 +43,8 @@ import {getMessages} from "@/util"; export type State = { version: string; + firstLoad: boolean; + servers: Map; configuration: LiveAtlasServerConfig; configurationHash: number | undefined; @@ -100,6 +102,7 @@ export type State = { export const state: State = { version: (process.env.VITE_APP_VERSION || 'Unknown') as string, + firstLoad: true, servers: new Map(), configuration: {