Fix crashes

This commit is contained in:
Arkadiusz Fal
2022-12-21 18:13:41 +01:00
parent 6594d5ba95
commit 18cbbd3c90
8 changed files with 26 additions and 17 deletions

View File

@@ -99,10 +99,11 @@ struct OpenURLHandler {
Windows.main.open()
#endif
player.videoBeingOpened = Video(app: accounts.current.app!, videoID: id)
let video = Video(app: accounts.current.app!, videoID: id)
player.videoBeingOpened = video
player
.playerAPI(player.videoBeingOpened!)
.playerAPI(video)?
.video(id)
.load()
.onSuccess { response in

View File

@@ -40,7 +40,9 @@ struct WatchView: View {
if finished, let watch {
PlayerModel.shared.removeWatch(watch)
} else {
Watch.markAsWatched(videoID: watch?.videoID ?? videoID, account: AccountsModel.shared.current, duration: watch?.videoDuration ?? duration, context: backgroundContext)
if let account = AccountsModel.shared.current {
Watch.markAsWatched(videoID: watch?.videoID ?? videoID, account: account, duration: watch?.videoDuration ?? duration, context: backgroundContext)
}
}
FeedModel.shared.calculateUnwatchedFeed()

View File

@@ -47,7 +47,7 @@ struct ShareButton<LabelView: View>: View {
private var instanceActions: some View {
Group {
Button(labelForShareURL(accounts.app.name)) {
if let url = player.playerAPI(contentItem.video).shareURL(contentItem) {
if let url = player.playerAPI(contentItem.video)?.shareURL(contentItem) {
shareAction(url)
} else {
navigation.presentAlert(
@@ -59,12 +59,16 @@ struct ShareButton<LabelView: View>: View {
if contentItemIsPlayerCurrentVideo {
Button(labelForShareURL(accounts.app.name, withTime: true)) {
shareAction(
player.playerAPI(player.currentVideo!).shareURL(
contentItem,
time: player.backend.currentTime
)!
)
if let video = player.videoForDisplay,
let api = player.playerAPI(video)
{
shareAction(
api.shareURL(
contentItem,
time: player.backend.currentTime
)!
)
}
}
}
}
@@ -93,7 +97,7 @@ struct ShareButton<LabelView: View>: View {
}
private var contentItemIsPlayerCurrentVideo: Bool {
contentItem.contentType == .video && contentItem.video?.videoID == player.currentVideo?.videoID
contentItem.contentType == .video && contentItem.video?.videoID == player.videoForDisplay?.videoID
}
@ViewBuilder private var remoteURLAction: some View {