Fix login button, close on 'move to home location'

This commit is contained in:
Pieter Vander Vennet 2022-12-21 01:39:16 +01:00
parent 8498754e10
commit cfd47ec30c

View file

@ -40,7 +40,8 @@ class UserInformationMainPanel extends Combine {
constructor(
osmConnection: OsmConnection,
locationControl: UIEventSource<Loc>,
layout: LayoutConfig
layout: LayoutConfig,
isOpened: UIEventSource<boolean>
) {
const t = Translations.t.userinfo
const imgSize = "h-6 w-6"
@ -50,8 +51,8 @@ class UserInformationMainPanel extends Combine {
ud.map((ud) => {
if (!ud?.loggedIn) {
// Not logged in
return new SubtleButton(Svg.login_svg(), "Login", { imgSize }).onClick(
osmConnection.AttemptLogin
return new SubtleButton(Svg.login_svg(), "Login", { imgSize }).onClick(() =>
osmConnection.AttemptLogin()
)
}
@ -96,6 +97,7 @@ class UserInformationMainPanel extends Combine {
return
}
locationControl.setData({ ...home, zoom: 16 })
isOpened.setData(false)
})
}
@ -143,7 +145,7 @@ export default class UserInformationPanel extends ScrollableFullScreen {
osmConnection: OsmConnection
locationControl: UIEventSource<Loc>
}) {
const t = Translations.t.general
const isOpened = new UIEventSource<boolean>(false)
super(
() => {
return new VariableUiElement(
@ -154,10 +156,12 @@ export default class UserInformationPanel extends ScrollableFullScreen {
return new UserInformationMainPanel(
state.osmConnection,
state.locationControl,
state.layoutToUse
state.layoutToUse,
isOpened
)
},
"userinfo"
"userinfo",
isOpened
)
}
}