[skip ci] profile service job fixes
This commit is contained in:
1 parent
673d6b3602
commit
115b457241
7 files changed
+39
-21
No files matched your search
+2
-1
@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix Invidious tests - `Me at the zoo` video was getting blocked
|
||||
- Invidious tests - `Me at the zoo` video was getting blocked
|
||||
- Bug where logging out from inactive profile is not properly persisted
|
||||
|
||||
### Removed
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@
|
||||
preferences="bind:../Preferences" />
|
||||
|
||||
<ProfilesService id="ProfilesService"
|
||||
invidious="bind:../Invidious" />
|
||||
invidious="bind:../Invidious"
|
||||
jobQueue="bind:/JobQueue" />
|
||||
|
||||
<Innertube id="Innertube"
|
||||
jobQueue="bind:/JobQueue" />
|
||||
|
||||
@@ -32,7 +32,8 @@ function InitializeBindings()
|
||||
"preferences": "../Preferences"
|
||||
},
|
||||
"ProfilesService": {
|
||||
"invidious": "../Invidious"
|
||||
"invidious": "../Invidious",
|
||||
"jobQueue": "/JobQueue"
|
||||
},
|
||||
"Innertube": {
|
||||
"jobQueue": "/JobQueue"
|
||||
|
||||
+13
-4
@@ -1,7 +1,9 @@
|
||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
|
||||
@asynctask
|
||||
function ProfilesInvidiousUnregisterTokenTask(input as object) as object
|
||||
@job("ProfilesInvidiousUnregisterTokenJob")
|
||||
function ExecuteJob() as void
|
||||
input = JobGetInput()
|
||||
|
||||
profileContentNodes = input.profileNodes
|
||||
invidiousNode = input.invidious
|
||||
|
||||
@@ -16,7 +18,14 @@ function ProfilesInvidiousUnregisterTokenTask(input as object) as object
|
||||
if not response.IsSuccess()
|
||||
LogWarn(`Failed to unregister token: ${response.ErrorMessage()}`)
|
||||
end if
|
||||
end for
|
||||
|
||||
return invalid
|
||||
refreshToken = profileNode.refreshToken
|
||||
if not StringUtils.IsNullOrEmpty(refreshToken)
|
||||
authToken.token = refreshToken
|
||||
response = service.UnregisterToken(authToken)
|
||||
if not response.IsSuccess()
|
||||
LogWarn(`Failed to unregister refresh token: ${response.ErrorMessage()}`)
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
@@ -1,5 +1,5 @@
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/components/JobSystem/Jobs.bs"
|
||||
import "pkg:/components/JobSystem/JobSystem.bs"
|
||||
import "pkg:/source/utils/ArrayUtils.bs"
|
||||
import "pkg:/source/utils/ColorUtils.bs"
|
||||
import "pkg:/source/utils/CryptoUtils.bs"
|
||||
@@ -83,11 +83,12 @@ function LoadProfilesFromRegistry()
|
||||
end if
|
||||
|
||||
if profileNodes.Count() > 0
|
||||
AsyncTask.Start(Tasks.ProfilesVerifyTokensTask, {
|
||||
input = {
|
||||
profilesService: m.top
|
||||
invidious: m.invidious
|
||||
profileNodes: profileNodes
|
||||
})
|
||||
}
|
||||
JobSystem.QueueJob(m.jobQueue, Jobs.ProfilesVerifyTokensJob, input)
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -245,14 +246,16 @@ function LogoutWithProfile(profile as object) as void
|
||||
SetCurrentProfile(invalid)
|
||||
else
|
||||
RefreshActiveProfileState(currentProfile)
|
||||
SaveUserProfilesToRegistry(invalid)
|
||||
end if
|
||||
|
||||
m.top.onProfileLogout = true
|
||||
|
||||
AsyncTask.Start(Tasks.ProfilesInvidiousUnregisterTokenTask, {
|
||||
input = {
|
||||
invidious: m.invidious
|
||||
profileNodes: [profile]
|
||||
})
|
||||
}
|
||||
JobSystem.QueueJob(m.jobQueue, Jobs.ProfilesInvidiousUnregisterTokenJob, input)
|
||||
end function
|
||||
|
||||
function LogoutWithProfiles(profiles as object) as void
|
||||
@@ -280,17 +283,18 @@ function LogoutWithProfiles(profiles as object) as void
|
||||
SetCurrentProfile(invalid)
|
||||
else
|
||||
RefreshActiveProfileState(currentProfile)
|
||||
SaveUserProfilesToRegistry(invalid)
|
||||
end if
|
||||
|
||||
if onProfileLogout
|
||||
m.top.onProfileLogout = true
|
||||
end if
|
||||
|
||||
AsyncTask.Start(Tasks.ProfilesInvidiousUnregisterTokenTask, {
|
||||
profiles: m.top
|
||||
input = {
|
||||
invidious: m.invidious
|
||||
profileNodes: profiles
|
||||
})
|
||||
}
|
||||
JobSystem.QueueJob(m.jobQueue, Jobs.ProfilesInvidiousUnregisterTokenJob, input)
|
||||
end function
|
||||
|
||||
function LogoutWithAccessToken(accessToken as dynamic) as void
|
||||
@@ -312,6 +316,7 @@ function LogoutWithAccessToken(accessToken as dynamic) as void
|
||||
SetCurrentProfile(invalid)
|
||||
else
|
||||
RefreshActiveProfileState(currentProfile)
|
||||
SaveUserProfilesToRegistry(invalid)
|
||||
end if
|
||||
m.top.onProfileLogout = true
|
||||
exit for
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<field id="content" type="node" />
|
||||
|
||||
<field id="invidious" type="node" />
|
||||
<field id="jobQueue" type="node" />
|
||||
|
||||
<function name="GetProfilesDto" />
|
||||
<function name="LoginWithProfile" />
|
||||
|
||||
+5
-5
@@ -1,8 +1,10 @@
|
||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
@asynctask
|
||||
function ProfilesVerifyTokensTask(input as object) as object
|
||||
@job("ProfilesVerifyTokensJob")
|
||||
function ExecuteJob() as void
|
||||
input = JobGetInput()
|
||||
|
||||
profilesNode = input.profilesService
|
||||
invidiousNode = input.invidious
|
||||
profileContentNodes = input.profileNodes
|
||||
@@ -20,7 +22,7 @@ function ProfilesVerifyTokensTask(input as object) as object
|
||||
end for
|
||||
|
||||
if invalidProfiles.Count() = 0
|
||||
return invalid
|
||||
return
|
||||
end if
|
||||
|
||||
profilesNode@.LogoutWithProfiles(invalidProfiles)
|
||||
@@ -36,6 +38,4 @@ function ProfilesVerifyTokensTask(input as object) as object
|
||||
message: message
|
||||
title: Tr(Locale.Dialogs.UserLoggedOut)
|
||||
})
|
||||
|
||||
return invalid
|
||||
end function
|
||||
Reference in new issue
Block a user