Initial PeerTube Support

This commit is contained in:
Arkadiusz Fal
2022-12-09 01:15:19 +01:00
parent 72ea17b257
commit faf2469e04
39 changed files with 816 additions and 92 deletions

View File

@@ -34,7 +34,6 @@ struct HistoryView: View {
.onAppear {
visibleWatches
.prefix(Self.detailsPreloadLimit)
.map(\.videoID)
.forEach(player.loadHistoryVideoDetails)
}
#if os(tvOS)

View File

@@ -82,7 +82,7 @@ struct AppSidebarNavigation: View {
.help(
"Switch Instances and Accounts\n" +
"Current Instance: \n" +
"\(accounts.current?.url ?? "Not Set")\n" +
"\(accounts.current?.urlString ?? "Not Set")\n" +
"Current User: \(accounts.current?.description ?? "Not set")"
)
}

View File

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

View File

@@ -58,7 +58,7 @@ struct SearchView: View {
VStack {
SearchTextField(favoriteItem: $favoriteItem)
if state.query.query != state.queryText {
if accounts.app.supportsSearchSuggestions, state.query.query != state.queryText {
SearchSuggestions()
.opacity(state.queryText.isEmpty ? 0 : 1)
} else {
@@ -72,7 +72,7 @@ struct SearchView: View {
results
#if os(macOS)
if state.query.query != state.queryText {
if accounts.app.supportsSearchSuggestions, state.query.query != state.queryText {
HStack {
Spacer()
SearchSuggestions()
@@ -122,6 +122,9 @@ struct SearchView: View {
state.store.replace(ContentItem.array(of: videos))
}
}
.onChange(of: accounts.current) { _ in
state.reloadQuery()
}
.onChange(of: state.queryText) { newQuery in
if newQuery.isEmpty {
favoriteItem = nil

View File

@@ -143,8 +143,8 @@ struct AccountForm: View {
private var validator: AccountValidator {
AccountValidator(
app: .constant(instance.app),
url: instance.apiURL,
account: Account(instanceID: instance.id, url: instance.apiURL, username: username, password: password),
url: instance.apiURLString,
account: Account(instanceID: instance.id, urlString: instance.apiURLString, username: username, password: password),
id: $username,
isValid: $isValid,
isValidated: $isValidated,

View File

@@ -100,7 +100,7 @@ struct LocationsSettings: View {
@ViewBuilder var countryFooter: some View {
if let account = accounts.current {
let locationType = account.isPublic ? (account.country ?? "Unknown") : "Custom".localized()
let description = account.isPublic ? account.url : account.instance?.description ?? "unknown".localized()
let description = account.isPublic ? account.urlString : account.instance?.description ?? "unknown".localized()
Text("Current: \(locationType)\n\(description)")
.foregroundColor(.secondary)

View File

@@ -14,7 +14,7 @@ struct VideoCell: View {
@Environment(\.verticalSizeClass) private var verticalSizeClass
#endif
@ObservedObject var thumbnails = ThumbnailsModel.shared
@ObservedObject private var thumbnails = ThumbnailsModel.shared
@Default(.channelOnThumbnail) private var channelOnThumbnail
@Default(.timeOnThumbnail) private var timeOnThumbnail

View File

@@ -20,6 +20,7 @@ struct ShareButton<LabelView: View>: View {
}
@ViewBuilder var body: some View {
// TODO: this should work with other content item types
if let video = contentItem.video, !video.localStreamIsFile {
Menu {
if video.localStreamIsRemoteURL {
@@ -44,7 +45,7 @@ struct ShareButton<LabelView: View>: View {
private var instanceActions: some View {
Group {
Button(labelForShareURL(accounts.app.name)) {
if let url = player.playerAPI.shareURL(contentItem) {
if let url = player.playerAPI(contentItem.video).shareURL(contentItem) {
shareAction(url)
} else {
navigation.presentAlert(
@@ -57,7 +58,7 @@ struct ShareButton<LabelView: View>: View {
if contentItemIsPlayerCurrentVideo {
Button(labelForShareURL(accounts.app.name, withTime: true)) {
shareAction(
player.playerAPI.shareURL(
player.playerAPI(player.currentVideo!).shareURL(
contentItem,
time: player.backend.currentTime
)!

View File

@@ -148,7 +148,7 @@ struct VideoContextMenuView: View {
var markAsWatchedButton: some View {
Button {
Watch.markAsWatched(videoID: video.videoID, duration: video.length, context: backgroundContext)
Watch.markAsWatched(videoID: video.videoID, account: accounts.current, duration: video.length, context: backgroundContext)
} label: {
Label("Mark as watched", systemImage: "checkmark.circle.fill")
}