Skip to content

Commit

Permalink
wip teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
glouel committed Nov 1, 2022
1 parent 9502855 commit 48af6a0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Aerial/Source/Models/Cache/Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -703,14 +703,14 @@ struct Cache {
return
}

debugLog("Looking for hidden videos to delete...")

// Step 1 : Delete hidden videos
debugLog("Looking for hidden videos to delete...")
for video in VideoList.instance.videos.filter({ PrefsVideos.hidden.contains($0.id) && $0.isAvailableOffline }) {
debugLog("Deleting hidden video \(video.secondaryName)")
do {
let path = VideoList.instance.localPathFor(video: video)
try FileManager.default.removeItem(atPath: path)
// try FileManager.default.removeItem(atPath: VideoCache.cachePath(forVideo: video)!)
} catch {
errorLog("Could not delete video : \(video.secondaryName)")
}
Expand Down
50 changes: 29 additions & 21 deletions Aerial/Source/Views/AerialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,6 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {

debugLog("\(self.description) deinit AerialView")
NotificationCenter.default.removeObserver(self)

// set player item to nil if not preview player
if player != AerialView.previewPlayer {
player?.rate = 0
player?.replaceCurrentItem(with: nil)
}

guard let player = self.player else {
return
}

// Remove from player index
let indexMaybe = AerialView.players.firstIndex(of: player)

guard let index = indexMaybe else {
return
}
AerialView.players.remove(at: index)
}

func ensureCorrectFormat() {
Expand Down Expand Up @@ -431,8 +413,35 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
brightnessToRestore = nil
}
}

teardown()
}

func teardown() {
// Remove notifications observer
clearNotifications()
// Clear layer animations
clearAllLayerAnimations()



guard let player = self.player else {
return
}
// Remove from player index
let indexMaybe = AerialView.players.firstIndex(of: player)

guard let index = indexMaybe else {
return
}
AerialView.players.remove(at: index)

// Remove any download
VideoManager.sharedInstance.cancelAll()

debugLog("end teardown")
}

// Wait for the player to be ready
// swiftlint:disable:next block_based_kvo
internal override func observeValue(forKeyPath keyPath: String?,
Expand Down Expand Up @@ -479,9 +488,8 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
}

func clearNotifications() {
let notificationCenter = NotificationCenter.default

notificationCenter.removeObserver(self)
NotificationCenter.default.removeObserver(self)
DistributedNotificationCenter.default.removeObserver(self)
}

func setNotifications(_ currentItem: AVPlayerItem) {
Expand Down
6 changes: 3 additions & 3 deletions Resources/MainUI/Settings panels/OverlaysViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -1068,15 +1068,15 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<textFieldCell key="cell" selectable="YES" id="yQd-AC-jyQ">
<font key="font" metaFont="message" size="11"/>
<string key="title">Aerial uses OpenWeather's API to retrieve and display current conditions and forecasts. In order for this to work, you will need to specify your location. There are two ways to do that:
<mutableString key="title">Aerial uses OpenWeather's API to retrieve and display current conditions and forecasts. In order for this to work, you will need to specify your location. There are two ways to do that:

- Manually specify : Simply enter your location (the name of your city, followed by a state abbreviation or country, such as "Paris, FR" or "Cupertino, CA".
- Manually specify : Simply enter your location as the name of your city, followed by a country abbreviation. To avoid disambiguation, you can also add a state when applicable (e.g. Cupertino, CA, USA).

- Use current location : For this to work, Aerial will ask your mac for your current location, which is provided by macOS location services. This information is then sent to OpenWeather's API to retrieve conditions to the city closest to the location specified.

For privacy reasons, the coordinates of your location are rounded to two decimals, leaving a precision of about 1 km. Please note that you will need to allow Aerial to use location services for this to work. In macOS Big Sur, please navigate to System Preferences &gt; Security &amp; Privacy &gt; Privacy &gt; Location Services and enable "legacyScreenSaver"

Independant of your choice, you can preview the results using the "Test" button below. </string>
Independant of your choice, you can preview the results using the "Test" button below. </mutableString>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
Expand Down

0 comments on commit 48af6a0

Please sign in to comment.