Added a "login" button in expired session profiles
This commit is contained in:
1 parent
33a243388f
commit
a134e1f50e
10 files changed
+137
-59
No files matched your search
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Video Player HUD now focuses initially on the trackbar, instead of the pause button
|
||||
- Pressing back cancels seek, hides UI, then closes the video player
|
||||
- Scrubbing accelerates on long videos
|
||||
- Added a "login" button in expired session profiles
|
||||
|
||||
## [0.48.1] - 2026-07-04
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
import "pkg:/source/utils/UrlUtils.bs"
|
||||
|
||||
function Init()
|
||||
m.urlLabel = m.top.findNode("urlLabel")
|
||||
@@ -17,7 +18,12 @@ function OnNodeReady()
|
||||
address = m.webserver@.GetServerAddress()
|
||||
isValidAddress = not StringUtils.IsNullOrEmpty(address)
|
||||
if isValidAddress
|
||||
m.top.url = `${address}/invidious/login`
|
||||
url = `${address}/invidious/login`
|
||||
serverUrl = m.top.serverUrl
|
||||
if not StringUtils.IsNullOrEmpty(serverUrl)
|
||||
url = UrlUtils.AppendQueryParams(url, { server: serverUrl })
|
||||
end if
|
||||
m.top.url = url
|
||||
else
|
||||
m.urlLabel.text = Tr(Locale.Dialogs.IpAddressNotAvailable)
|
||||
end if
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<field id="webServer" type="node" bind="/WebServer" />
|
||||
<field id="profilesService" type="node" bind="/ProfilesService" />
|
||||
<field id="url" type="string" onChange="OnUrlSet" />
|
||||
<field id="serverUrl" type="string" />
|
||||
<field id="alwaysOnTop" type="boolean" />
|
||||
</interface>
|
||||
<children>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace LoginUtils
|
||||
|
||||
function ShowInvidiousLoginDialog(serverUrl = "" as string) as void
|
||||
dialog = CreateObject("roSGNode", "InvidiousLoginDialog")
|
||||
dialog.serverUrl = serverUrl
|
||||
dialog@.BindNode()
|
||||
m.top.getScene().dialog = dialog
|
||||
end function
|
||||
|
||||
function ShowLoginWithYouTubeDisclaimerDialog() as void
|
||||
dialog = DialogUtils.ShowDialogEx({
|
||||
title: Tr(Locale.Dialogs.Disclaimer)
|
||||
message: [
|
||||
Tr(Locale.Dialogs.YouTubeLoginDisclaimer1)
|
||||
Tr(Locale.Dialogs.YouTubeLoginDisclaimer2)
|
||||
Tr(Locale.Dialogs.YouTubeLoginDisclaimer3)
|
||||
]
|
||||
large: true
|
||||
buttons: [
|
||||
Tr(Locale.Buttons.OK)
|
||||
Tr(Locale.Buttons.Cancel)
|
||||
]
|
||||
})
|
||||
dialog.ObserveField("buttonSelected", FuncName(LoginUtils.OnLoginWithYouTubeDisclaimerDialogButtonSelected))
|
||||
end function
|
||||
|
||||
function OnLoginWithYouTubeDisclaimerDialogButtonSelected(event as object) as void
|
||||
buttonSelected = event.getData()
|
||||
if buttonSelected <> 0
|
||||
return
|
||||
end if
|
||||
|
||||
LoginUtils.ShowYouTubeLoginDialog()
|
||||
end function
|
||||
|
||||
function ShowYouTubeLoginDialog() as void
|
||||
dialog = CreateObject("roSGNode", "YouTubeLoginDialog")
|
||||
dialog@.BindNode()
|
||||
m.top.getScene().dialog = dialog
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -1,6 +1,7 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionViewUtils.bs"
|
||||
import "pkg:/components/Screens/ProfileScreen/LoginUtils.bs"
|
||||
import "pkg:/components/Screens/ProfileScreen/ProfileView/ProfileViewUtils.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
@@ -54,15 +55,15 @@ function OnBackEndSelected(event as object) as void
|
||||
|
||||
selectedBackendType = event.getData()
|
||||
if selectedBackendType = "BackendTypeInvidious"
|
||||
LoginWithInvidious()
|
||||
OnLoginWithInvidiousSelected()
|
||||
else if selectedBackendType = "BackendTypeYouTube"
|
||||
ShowLoginWithYouTubeDialog()
|
||||
LoginUtils.ShowLoginWithYouTubeDisclaimerDialog()
|
||||
else
|
||||
LogError("Unknown backend type:", selectedBackendType)
|
||||
end if
|
||||
end function
|
||||
|
||||
function LoginWithInvidious() as void
|
||||
function OnLoginWithInvidiousSelected() as void
|
||||
invidiousInstance = m.preferences["invidious.instance"]
|
||||
if StringUtils.IsNullOrEmpty(invidiousInstance)
|
||||
DialogUtils.ShowDialogEx({
|
||||
@@ -75,41 +76,7 @@ function LoginWithInvidious() as void
|
||||
return
|
||||
end if
|
||||
|
||||
dialog = CreateObject("roSGNode", "InvidiousLoginDialog")
|
||||
dialog@.BindNode()
|
||||
m.top.getScene().dialog = dialog
|
||||
end function
|
||||
|
||||
function ShowLoginWithYouTubeDialog() as void
|
||||
dialog = DialogUtils.ShowDialogEx({
|
||||
title: Tr(Locale.Dialogs.Disclaimer)
|
||||
message: [
|
||||
Tr(Locale.Dialogs.YouTubeLoginDisclaimer1)
|
||||
Tr(Locale.Dialogs.YouTubeLoginDisclaimer2)
|
||||
Tr(Locale.Dialogs.YouTubeLoginDisclaimer3)
|
||||
]
|
||||
large: true
|
||||
buttons: [
|
||||
Tr(Locale.Buttons.OK)
|
||||
Tr(Locale.Buttons.Cancel)
|
||||
]
|
||||
})
|
||||
dialog.ObserveField("buttonSelected", FuncName(OnLoginWithYouTubeDialogButtonSelected))
|
||||
end function
|
||||
|
||||
function OnLoginWithYouTubeDialogButtonSelected(event as object) as void
|
||||
buttonSelected = event.getData()
|
||||
if buttonSelected <> 0
|
||||
return
|
||||
end if
|
||||
|
||||
LoginWithYouTube()
|
||||
end function
|
||||
|
||||
function LoginWithYouTube() as void
|
||||
dialog = CreateObject("roSGNode", "YouTubeLoginDialog")
|
||||
dialog@.BindNode()
|
||||
m.top.getScene().dialog = dialog
|
||||
LoginUtils.ShowInvidiousLoginDialog()
|
||||
end function
|
||||
|
||||
function OnCurrentProfileChanged() as void
|
||||
|
||||
@@ -1,28 +1,39 @@
|
||||
import "pkg:/components/ContentNode/ProfileContentAuthTokenUtils.types.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/Screens/ProfileScreen/LoginUtils.bs"
|
||||
import "pkg:/source/utils/DisposableObserve.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.loginButton = m.top.findNode("loginButton")
|
||||
m.activateButton = m.top.findNode("activateButton")
|
||||
m.logoutButton = m.top.findNode("logoutButton")
|
||||
m.closeButton = m.top.findNode("closeButton")
|
||||
m.reauthLabel = m.top.findNode("ReauthLabel")
|
||||
|
||||
m.loginButton.disabled = true
|
||||
m.needsReauth = false
|
||||
|
||||
DisposableObserveField(m.loginButton, "buttonSelected", FuncName(Login))
|
||||
DisposableObserveField(m.activateButton, "buttonSelected", FuncName(Activate))
|
||||
DisposableObserveField(m.logoutButton, "buttonSelected", FuncName(Logout))
|
||||
DisposableObserveField(m.closeButton, "buttonSelected", FuncName(Close))
|
||||
end function
|
||||
|
||||
function OnNodeReady()
|
||||
SetNavigation(m.loginButton, RemoteKeys.Down, m.activateButton)
|
||||
SetNavigation(m.activateButton, RemoteKeys.Up, m.loginButton)
|
||||
SetNavigation(m.activateButton, RemoteKeys.Down, m.logoutButton)
|
||||
SetNavigation(m.logoutButton, RemoteKeys.Down, m.closeButton)
|
||||
SetNavigation(m.closeButton, RemoteKeys.Up, m.logoutButton)
|
||||
SetNavigation(m.logoutButton, RemoteKeys.Up, m.activateButton)
|
||||
SetNavigation(m.loginButton, RemoteKeys.Down, m.logoutButton)
|
||||
SetNavigation(m.logoutButton, RemoteKeys.Up, m.loginButton)
|
||||
|
||||
DisposableObserveFieldScoped(m.profilesService, "currentProfile", FuncName(OnCunrrentProfileChanged))
|
||||
DisposableObserveFieldScoped(m.profilesService, "onProfileLogout", FuncName(OnProfileLogout))
|
||||
@@ -31,7 +42,10 @@ end function
|
||||
function OnContentSet() as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
m.needsReauth = false
|
||||
m.reauthLabel.visible = false
|
||||
m.loginButton.visible = false
|
||||
m.loginButton.disabled = true
|
||||
return
|
||||
end if
|
||||
|
||||
@@ -73,17 +87,21 @@ function OnContentSet() as void
|
||||
m.top.backendTypePosterUri = ""
|
||||
end if
|
||||
|
||||
UpdateReauthState(content)
|
||||
UpdateReauthState(content.authState)
|
||||
|
||||
UpdateActivateButton()
|
||||
UpdateActivateButton(content.isSelected)
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
if m.top.focus
|
||||
FocusTopButton()
|
||||
end if
|
||||
end function
|
||||
|
||||
if m.activateButton.focusable
|
||||
function FocusTopButton() as void
|
||||
if m.loginButton.focusable
|
||||
NodeSetFocus(m.loginButton, true)
|
||||
else if m.activateButton.focusable
|
||||
NodeSetFocus(m.activateButton, true)
|
||||
else
|
||||
NodeSetFocus(m.logoutButton, true)
|
||||
@@ -108,6 +126,22 @@ function OnKeyEvent(key as string, press as boolean) as boolean
|
||||
return true
|
||||
end function
|
||||
|
||||
function Login() as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
backendType = content.type
|
||||
if backendType = "invidious"
|
||||
LoginUtils.ShowInvidiousLoginDialog(ValidString(content.serverUrl))
|
||||
else if backendType = "youtube"
|
||||
LoginUtils.ShowYouTubeLoginDialog()
|
||||
else
|
||||
LogError("Unknown backend type:", backendType)
|
||||
end if
|
||||
end function
|
||||
|
||||
function Activate() as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
@@ -145,15 +179,27 @@ function OnDispose()
|
||||
m.top.content = invalid
|
||||
end function
|
||||
|
||||
function UpdateReauthState(content as object) as void
|
||||
needsReauth = content.authState = ProfileContentAuthTokenUtils.ProfileAuthState.NeedsReauth
|
||||
function UpdateReauthState(authState as string) as void
|
||||
needsReauth = authState = ProfileContentAuthTokenUtils.ProfileAuthState.NeedsReauth
|
||||
if needsReauth = m.needsReauth
|
||||
return
|
||||
end if
|
||||
m.needsReauth = needsReauth
|
||||
|
||||
if needsReauth
|
||||
m.reauthLabel.text = [
|
||||
Tr(Locale.Dialogs.ProfileNeedsReauthMessageLine1)
|
||||
Tr(Locale.Dialogs.ProfileNeedsReauthMessageLine2)
|
||||
].Join(Chr(10))
|
||||
m.loginButton.text = Tr(Locale.Buttons.Login)
|
||||
end if
|
||||
m.reauthLabel.visible = needsReauth
|
||||
m.loginButton.visible = needsReauth
|
||||
m.loginButton.disabled = not needsReauth
|
||||
|
||||
if m.top.isInFocusChain()
|
||||
FocusTopButton()
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnCunrrentProfileChanged() as void
|
||||
@@ -162,7 +208,7 @@ function OnCunrrentProfileChanged() as void
|
||||
return
|
||||
end if
|
||||
m.top.crownVisible = content.isSelected
|
||||
UpdateActivateButton()
|
||||
UpdateActivateButton(content.isSelected)
|
||||
end function
|
||||
|
||||
function OnProfileLogout() as void
|
||||
@@ -177,13 +223,7 @@ function OnProfileLogout() as void
|
||||
end if
|
||||
end function
|
||||
|
||||
function UpdateActivateButton() as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
isSelected = content.isSelected
|
||||
function UpdateActivateButton(isSelected as boolean) as void
|
||||
if isSelected
|
||||
if m.activateButton.hasFocus()
|
||||
NodeSetFocus(m.logoutButton, true)
|
||||
|
||||
@@ -79,6 +79,13 @@
|
||||
</Label>
|
||||
</Group>
|
||||
|
||||
<ButtonEx
|
||||
id="loginButton"
|
||||
iconVisible="false"
|
||||
anchor="[0.5,0.5]"
|
||||
minWidth="200"
|
||||
translation="[520,64]"
|
||||
visible="false" />
|
||||
<ButtonEx
|
||||
id="activateButton"
|
||||
iconVisible="false"
|
||||
|
||||
@@ -13,6 +13,6 @@ function GetInvidiousInstance(_unused as dynamic) as string
|
||||
return m.service.GetInvidiousInstance()
|
||||
end function
|
||||
|
||||
function GetAuthorizeTokenLink(_unused as dynamic) as dynamic
|
||||
return m.service.GetAuthorizeTokenLink()
|
||||
function GetAuthorizeTokenLink(serverUrl as dynamic) as dynamic
|
||||
return m.service.GetAuthorizeTokenLink(ValidString(serverUrl))
|
||||
end function
|
||||
@@ -742,8 +742,11 @@ namespace Invidious
|
||||
return request.Await()
|
||||
end function
|
||||
|
||||
function GetAuthorizeTokenLink() as dynamic
|
||||
instance = m.GetInvidiousInstance()
|
||||
function GetAuthorizeTokenLink(serverUrl = "" as string) as dynamic
|
||||
instance = serverUrl
|
||||
if StringUtils.IsNullOrEmpty(instance)
|
||||
instance = m.GetInvidiousInstance()
|
||||
end if
|
||||
if StringUtils.IsNullOrEmpty(instance)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
@@ -18,9 +18,16 @@ namespace Http
|
||||
|
||||
@get("/invidious/login")
|
||||
function Login(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
authLink = m.invidiousNode@.GetAuthorizeTokenLink()
|
||||
server = ValidString(request.query["server"])
|
||||
|
||||
authLink = m.invidiousNode@.GetAuthorizeTokenLink(server)
|
||||
if authLink = invalid
|
||||
response.Default(503, "Invidious server not configured")
|
||||
return true
|
||||
end if
|
||||
response.Redirect(authLink)
|
||||
return true
|
||||
end function
|
||||
|
||||
Reference in new issue
Block a user