Skip to content

Commit

Permalink
Fix local repository, update to latest beta
Browse files Browse the repository at this point in the history
  • Loading branch information
glouel committed May 13, 2023
1 parent d20cefc commit a581dd3
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ DerivedData/
release/
debug.plist
Examples/debug.html
Aerial/Source/Models/API/APISecrets.swift
6 changes: 4 additions & 2 deletions Aerial/Source/Models/Sources/SourceList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ struct SourceList {
}
}

static func updateLocalSource(source: Source) {
static func updateLocalSource(source: Source, reload: Bool) {
// We need the raw manifest to find the path inside
let videos = source.getUnprocessedVideos()

Expand Down Expand Up @@ -257,7 +257,9 @@ struct SourceList {

SourceList.saveEntries(source: source, manifest: videoManifest)

VideoList.instance.reloadSources()
if reload {
VideoList.instance.reloadSources()
}
} catch {
errorLog("Could not process directory")
}
Expand Down
22 changes: 21 additions & 1 deletion Aerial/Source/Models/Sources/VideoList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@ class VideoList {
}
}

for source in SourceList.list {
if source.type == .local {
debugLog("\(source.name) updating local source")
SourceList.updateLocalSource(source: source, reload: false)
}
}

if !sourceQueue.isEmpty {
// Now queue and download
for source in sourceQueue {
Expand Down Expand Up @@ -414,6 +421,12 @@ class VideoList {
return filteredVideosFor(mode, filter: PrefsVideos.newShouldPlayString)
}
}

func everythingRotation() -> [AerialVideo] {
return videos
.filter({ !PrefsVideos.hidden.contains($0.id) })
.sorted { $0.secondaryName < $1.secondaryName }
}

// MARK: - Playlist management
func generatePlaylist(isRestricted: Bool, restrictedTo: String, isVertical: Bool) {
Expand All @@ -424,9 +437,16 @@ class VideoList {
playlistRestrictedTo = restrictedTo
playlistHasVerticalVideos = false

let shuffled = currentRotation().shuffled()
var shuffled = currentRotation().shuffled()

// If we have nothing, just get everything
if shuffled.count == 0 {
shuffled = everythingRotation().shuffled()
}

let cachedShuffled = shuffled.filter({ $0.isAvailableOffline })


debugLog("Playlist raw count: \(shuffled.count) raw cached count \(cachedShuffled.count) isRestricted: \(isRestricted) restrictedTo: \(restrictedTo)")

if PrefsDisplays.viewingMode == .independent && PrefsAdvanced.favorOrientation {
Expand Down
2 changes: 1 addition & 1 deletion Aerial/Source/Views/AerialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
// This will lead to crashing in up to Ventura beta5 so disable
let debugTextView = NSTextView(frame: bounds.insetBy(dx: 20, dy: 20))
debugTextView.font = .labelFont(ofSize: 10)
debugTextView.string += "Preview is disabled on Ventura beta"
debugTextView.string += "HDR Previews hidden on Ventura"
isDisabled = true

self.addSubview(debugTextView)
Expand Down
19 changes: 14 additions & 5 deletions Aerial/Source/Views/Layers/DateLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,27 @@ class DateLayer: AnimationTextLayer {
} else {
template = "EEEE, MMMM dd"
}

dateFormatter.dateFormat = DateFormatter.dateFormat(fromTemplate: template, options: 0, locale: locale)
dateFormatter.locale = locale
return dateFormatter.string(from: Date()).capitalizeFirstLetter()

} else if config!.format == .compact {
if config!.withYear {
template = "MM/dd/yy"
} else {
template = "MM/dd"
}

dateFormatter.dateFormat = DateFormatter.dateFormat(fromTemplate: template, options: 0, locale: locale)
dateFormatter.locale = locale
return dateFormatter.string(from: Date()).capitalizeFirstLetter()
} else {
template = PrefsInfo.customDateFormat
}
let RFC3339DateFormatter = DateFormatter()
RFC3339DateFormatter.locale = Locale(identifier: "en_US_POSIX")
RFC3339DateFormatter.dateFormat = PrefsInfo.customDateFormat

dateFormatter.dateFormat = DateFormatter.dateFormat(fromTemplate: template, options: 0, locale: locale)
dateFormatter.locale = locale
return dateFormatter.string(from: Date()).capitalizeFirstLetter()
return RFC3339DateFormatter.string(from: Date())
}
}
}
2 changes: 1 addition & 1 deletion Aerial/Source/Views/Sources/DescriptionCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class DescriptionCellView: NSTableCellView {
VideoList.instance.downloadSource(source: source)
} else if source.type == .local {
debugLog("Checking local directory")
SourceList.updateLocalSource(source: source)
SourceList.updateLocalSource(source: source, reload: true)
} else {
debugLog("Refreshing non-cacheable source")
VideoList.instance.downloadSource(source: source)
Expand Down

0 comments on commit a581dd3

Please sign in to comment.