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
|
- 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
|
- Pressing back cancels seek, hides UI, then closes the video player
|
||||||
- Scrubbing accelerates on long videos
|
- Scrubbing accelerates on long videos
|
||||||
|
- Added a "login" button in expired session profiles
|
||||||
|
|
||||||
## [0.48.1] - 2026-07-04
|
## [0.48.1] - 2026-07-04
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import "pkg:/source/utils/Locale.bs"
|
import "pkg:/source/utils/Locale.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
import "pkg:/source/utils/UrlUtils.bs"
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
m.urlLabel = m.top.findNode("urlLabel")
|
m.urlLabel = m.top.findNode("urlLabel")
|
||||||
@@ -17,7 +18,12 @@ function OnNodeReady()
|
|||||||
address = m.webserver@.GetServerAddress()
|
address = m.webserver@.GetServerAddress()
|
||||||
isValidAddress = not StringUtils.IsNullOrEmpty(address)
|
isValidAddress = not StringUtils.IsNullOrEmpty(address)
|
||||||
if isValidAddress
|
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
|
else
|
||||||
m.urlLabel.text = Tr(Locale.Dialogs.IpAddressNotAvailable)
|
m.urlLabel.text = Tr(Locale.Dialogs.IpAddressNotAvailable)
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<field id="webServer" type="node" bind="/WebServer" />
|
<field id="webServer" type="node" bind="/WebServer" />
|
||||||
<field id="profilesService" type="node" bind="/ProfilesService" />
|
<field id="profilesService" type="node" bind="/ProfilesService" />
|
||||||
<field id="url" type="string" onChange="OnUrlSet" />
|
<field id="url" type="string" onChange="OnUrlSet" />
|
||||||
|
<field id="serverUrl" type="string" />
|
||||||
<field id="alwaysOnTop" type="boolean" />
|
<field id="alwaysOnTop" type="boolean" />
|
||||||
</interface>
|
</interface>
|
||||||
<children>
|
<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/Dialog/DialogUtils.bs"
|
||||||
import "pkg:/components/Navigation/Navigation.bs"
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
import "pkg:/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionViewUtils.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:/components/Screens/ProfileScreen/ProfileView/ProfileViewUtils.bs"
|
||||||
import "pkg:/source/utils/FocusManagement.bs"
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
@@ -54,15 +55,15 @@ function OnBackEndSelected(event as object) as void
|
|||||||
|
|
||||||
selectedBackendType = event.getData()
|
selectedBackendType = event.getData()
|
||||||
if selectedBackendType = "BackendTypeInvidious"
|
if selectedBackendType = "BackendTypeInvidious"
|
||||||
LoginWithInvidious()
|
OnLoginWithInvidiousSelected()
|
||||||
else if selectedBackendType = "BackendTypeYouTube"
|
else if selectedBackendType = "BackendTypeYouTube"
|
||||||
ShowLoginWithYouTubeDialog()
|
LoginUtils.ShowLoginWithYouTubeDisclaimerDialog()
|
||||||
else
|
else
|
||||||
LogError("Unknown backend type:", selectedBackendType)
|
LogError("Unknown backend type:", selectedBackendType)
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function LoginWithInvidious() as void
|
function OnLoginWithInvidiousSelected() as void
|
||||||
invidiousInstance = m.preferences["invidious.instance"]
|
invidiousInstance = m.preferences["invidious.instance"]
|
||||||
if StringUtils.IsNullOrEmpty(invidiousInstance)
|
if StringUtils.IsNullOrEmpty(invidiousInstance)
|
||||||
DialogUtils.ShowDialogEx({
|
DialogUtils.ShowDialogEx({
|
||||||
@@ -75,41 +76,7 @@ function LoginWithInvidious() as void
|
|||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
dialog = CreateObject("roSGNode", "InvidiousLoginDialog")
|
LoginUtils.ShowInvidiousLoginDialog()
|
||||||
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
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnCurrentProfileChanged() as void
|
function OnCurrentProfileChanged() as void
|
||||||
|
|||||||
@@ -1,28 +1,39 @@
|
|||||||
import "pkg:/components/ContentNode/ProfileContentAuthTokenUtils.types.bs"
|
import "pkg:/components/ContentNode/ProfileContentAuthTokenUtils.types.bs"
|
||||||
import "pkg:/components/Navigation/Navigation.bs"
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
|
import "pkg:/components/Screens/ProfileScreen/LoginUtils.bs"
|
||||||
import "pkg:/source/utils/DisposableObserve.bs"
|
import "pkg:/source/utils/DisposableObserve.bs"
|
||||||
import "pkg:/source/utils/FocusManagement.bs"
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
import "pkg:/source/utils/Locale.bs"
|
import "pkg:/source/utils/Locale.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/RemoteKeys.bs"
|
import "pkg:/source/utils/RemoteKeys.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
|
m.loginButton = m.top.findNode("loginButton")
|
||||||
m.activateButton = m.top.findNode("activateButton")
|
m.activateButton = m.top.findNode("activateButton")
|
||||||
m.logoutButton = m.top.findNode("logoutButton")
|
m.logoutButton = m.top.findNode("logoutButton")
|
||||||
m.closeButton = m.top.findNode("closeButton")
|
m.closeButton = m.top.findNode("closeButton")
|
||||||
m.reauthLabel = m.top.findNode("ReauthLabel")
|
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.activateButton, "buttonSelected", FuncName(Activate))
|
||||||
DisposableObserveField(m.logoutButton, "buttonSelected", FuncName(Logout))
|
DisposableObserveField(m.logoutButton, "buttonSelected", FuncName(Logout))
|
||||||
DisposableObserveField(m.closeButton, "buttonSelected", FuncName(Close))
|
DisposableObserveField(m.closeButton, "buttonSelected", FuncName(Close))
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnNodeReady()
|
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.activateButton, RemoteKeys.Down, m.logoutButton)
|
||||||
SetNavigation(m.logoutButton, RemoteKeys.Down, m.closeButton)
|
SetNavigation(m.logoutButton, RemoteKeys.Down, m.closeButton)
|
||||||
SetNavigation(m.closeButton, RemoteKeys.Up, m.logoutButton)
|
SetNavigation(m.closeButton, RemoteKeys.Up, m.logoutButton)
|
||||||
SetNavigation(m.logoutButton, RemoteKeys.Up, m.activateButton)
|
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, "currentProfile", FuncName(OnCunrrentProfileChanged))
|
||||||
DisposableObserveFieldScoped(m.profilesService, "onProfileLogout", FuncName(OnProfileLogout))
|
DisposableObserveFieldScoped(m.profilesService, "onProfileLogout", FuncName(OnProfileLogout))
|
||||||
@@ -31,7 +42,10 @@ end function
|
|||||||
function OnContentSet() as void
|
function OnContentSet() as void
|
||||||
content = m.top.content
|
content = m.top.content
|
||||||
if content = invalid
|
if content = invalid
|
||||||
|
m.needsReauth = false
|
||||||
m.reauthLabel.visible = false
|
m.reauthLabel.visible = false
|
||||||
|
m.loginButton.visible = false
|
||||||
|
m.loginButton.disabled = true
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -73,17 +87,21 @@ function OnContentSet() as void
|
|||||||
m.top.backendTypePosterUri = ""
|
m.top.backendTypePosterUri = ""
|
||||||
end if
|
end if
|
||||||
|
|
||||||
UpdateReauthState(content)
|
UpdateReauthState(content.authState)
|
||||||
|
|
||||||
UpdateActivateButton()
|
UpdateActivateButton(content.isSelected)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnFocusChange() as void
|
function OnFocusChange() as void
|
||||||
if not m.top.focus
|
if m.top.focus
|
||||||
return
|
FocusTopButton()
|
||||||
end if
|
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)
|
NodeSetFocus(m.activateButton, true)
|
||||||
else
|
else
|
||||||
NodeSetFocus(m.logoutButton, true)
|
NodeSetFocus(m.logoutButton, true)
|
||||||
@@ -108,6 +126,22 @@ function OnKeyEvent(key as string, press as boolean) as boolean
|
|||||||
return true
|
return true
|
||||||
end function
|
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
|
function Activate() as void
|
||||||
content = m.top.content
|
content = m.top.content
|
||||||
if content = invalid
|
if content = invalid
|
||||||
@@ -145,15 +179,27 @@ function OnDispose()
|
|||||||
m.top.content = invalid
|
m.top.content = invalid
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function UpdateReauthState(content as object) as void
|
function UpdateReauthState(authState as string) as void
|
||||||
needsReauth = content.authState = ProfileContentAuthTokenUtils.ProfileAuthState.NeedsReauth
|
needsReauth = authState = ProfileContentAuthTokenUtils.ProfileAuthState.NeedsReauth
|
||||||
|
if needsReauth = m.needsReauth
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
m.needsReauth = needsReauth
|
||||||
|
|
||||||
if needsReauth
|
if needsReauth
|
||||||
m.reauthLabel.text = [
|
m.reauthLabel.text = [
|
||||||
Tr(Locale.Dialogs.ProfileNeedsReauthMessageLine1)
|
Tr(Locale.Dialogs.ProfileNeedsReauthMessageLine1)
|
||||||
Tr(Locale.Dialogs.ProfileNeedsReauthMessageLine2)
|
Tr(Locale.Dialogs.ProfileNeedsReauthMessageLine2)
|
||||||
].Join(Chr(10))
|
].Join(Chr(10))
|
||||||
|
m.loginButton.text = Tr(Locale.Buttons.Login)
|
||||||
end if
|
end if
|
||||||
m.reauthLabel.visible = needsReauth
|
m.reauthLabel.visible = needsReauth
|
||||||
|
m.loginButton.visible = needsReauth
|
||||||
|
m.loginButton.disabled = not needsReauth
|
||||||
|
|
||||||
|
if m.top.isInFocusChain()
|
||||||
|
FocusTopButton()
|
||||||
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnCunrrentProfileChanged() as void
|
function OnCunrrentProfileChanged() as void
|
||||||
@@ -162,7 +208,7 @@ function OnCunrrentProfileChanged() as void
|
|||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
m.top.crownVisible = content.isSelected
|
m.top.crownVisible = content.isSelected
|
||||||
UpdateActivateButton()
|
UpdateActivateButton(content.isSelected)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnProfileLogout() as void
|
function OnProfileLogout() as void
|
||||||
@@ -177,13 +223,7 @@ function OnProfileLogout() as void
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function UpdateActivateButton() as void
|
function UpdateActivateButton(isSelected as boolean) as void
|
||||||
content = m.top.content
|
|
||||||
if content = invalid
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
|
|
||||||
isSelected = content.isSelected
|
|
||||||
if isSelected
|
if isSelected
|
||||||
if m.activateButton.hasFocus()
|
if m.activateButton.hasFocus()
|
||||||
NodeSetFocus(m.logoutButton, true)
|
NodeSetFocus(m.logoutButton, true)
|
||||||
|
|||||||
@@ -79,6 +79,13 @@
|
|||||||
</Label>
|
</Label>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
<ButtonEx
|
||||||
|
id="loginButton"
|
||||||
|
iconVisible="false"
|
||||||
|
anchor="[0.5,0.5]"
|
||||||
|
minWidth="200"
|
||||||
|
translation="[520,64]"
|
||||||
|
visible="false" />
|
||||||
<ButtonEx
|
<ButtonEx
|
||||||
id="activateButton"
|
id="activateButton"
|
||||||
iconVisible="false"
|
iconVisible="false"
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ function GetInvidiousInstance(_unused as dynamic) as string
|
|||||||
return m.service.GetInvidiousInstance()
|
return m.service.GetInvidiousInstance()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetAuthorizeTokenLink(_unused as dynamic) as dynamic
|
function GetAuthorizeTokenLink(serverUrl as dynamic) as dynamic
|
||||||
return m.service.GetAuthorizeTokenLink()
|
return m.service.GetAuthorizeTokenLink(ValidString(serverUrl))
|
||||||
end function
|
end function
|
||||||
@@ -742,8 +742,11 @@ namespace Invidious
|
|||||||
return request.Await()
|
return request.Await()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetAuthorizeTokenLink() as dynamic
|
function GetAuthorizeTokenLink(serverUrl = "" as string) as dynamic
|
||||||
instance = m.GetInvidiousInstance()
|
instance = serverUrl
|
||||||
|
if StringUtils.IsNullOrEmpty(instance)
|
||||||
|
instance = m.GetInvidiousInstance()
|
||||||
|
end if
|
||||||
if StringUtils.IsNullOrEmpty(instance)
|
if StringUtils.IsNullOrEmpty(instance)
|
||||||
return invalid
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -18,9 +18,16 @@ namespace Http
|
|||||||
|
|
||||||
@get("/invidious/login")
|
@get("/invidious/login")
|
||||||
function Login(context as object) as boolean
|
function Login(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
response = context.response
|
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)
|
response.Redirect(authLink)
|
||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|||||||
Reference in new issue
Block a user