Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix app crashes when refreshing episode list view #1837

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions source/Main.bs
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,28 @@ sub Main (args as dynamic) as void
else if isNodeEvent(msg, "refreshSeasonDetailsData")
startLoadingSpinner()

currentEpisode = m.global.queueManager.callFunc("getCurrentItem")
currentScene = m.global.sceneManager.callFunc("getActiveScene")

' Find the object in the scene's data and update its json data
for i = 0 to currentScene.objects.Items.count() - 1
if LCase(currentScene.objects.Items[i].id) = LCase(currentEpisode.id)
currentScene.objects.Items[i].json = api.users.GetItem(m.global.session.user.id, currentEpisode.id)
m.global.queueManager.callFunc("setTopStartingPoint", currentScene.objects.Items[i].json.UserData.PlaybackPositionTicks)
exit for
if isValid(currentScene) and isValid(currentScene.objects) and isValid(currentScene.seasonData)
currentEpisode = m.global.queueManager.callFunc("getCurrentItem")

if isValid(currentScene.objects.Items) and isValid(currentEpisode) and isValid(currentEpisode.id)
' Find the object in the scene's data and update its json data
for i = 0 to currentScene.objects.Items.count() - 1
if LCase(currentScene.objects.Items[i].id) = LCase(currentEpisode.id)
currentScene.objects.Items[i].json = api.users.GetItem(m.global.session.user.id, currentEpisode.id)
m.global.queueManager.callFunc("setTopStartingPoint", currentScene.objects.Items[i].json.UserData.PlaybackPositionTicks)
exit for
end if
end for
end if
end for

seasonMetaData = ItemMetaData(currentScene.seasonData.id)
currentScene.seasonData = seasonMetaData.json
currentScene.episodeObjects = currentScene.objects
currentScene.callFunc("updateSeason")
seasonMetaData = ItemMetaData(currentScene.seasonData.id)
currentScene.seasonData = seasonMetaData.json
currentScene.episodeObjects = currentScene.objects
currentScene.callFunc("updateSeason")
end if

stopLoadingSpinner()
else if isNodeEvent(msg, "refreshMovieDetailsData")
startLoadingSpinner()
Expand Down
Loading