From 08bd78d51bfc2b8b35561f1a8cf809060e908e1d Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 31 Mar 2024 20:51:28 -0400 Subject: [PATCH] Fix changing greyscale images preference breaking gifvs looping --- Tusker/Views/Attachments/GifvController.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tusker/Views/Attachments/GifvController.swift b/Tusker/Views/Attachments/GifvController.swift index 61ef74ee..b6e01f08 100644 --- a/Tusker/Views/Attachments/GifvController.swift +++ b/Tusker/Views/Attachments/GifvController.swift @@ -62,10 +62,14 @@ class GifvController { @objc private func preferencesChanged() { if isGrayscale != Preferences.shared.grayscaleImages { isGrayscale = Preferences.shared.grayscaleImages + let oldItem = item item = GifvController.createItem(asset: asset) player.replaceCurrentItem(with: item) self.updatePresentationSizeObservation() player.play() + + NotificationCenter.default.removeObserver(self, name: AVPlayerItem.didPlayToEndTimeNotification, object: oldItem) + NotificationCenter.default.addObserver(self, selector: #selector(restartItem), name: AVPlayerItem.didPlayToEndTimeNotification, object: item) } }