π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Trim slop comments from the cast app
Manav Rathi524f5a51e925
diff --git a/mobile/native/apple/apps/cast/Cast/Services/CastPairingService.swift b/mobile/native/apple/apps/cast/Cast/Services/CastPairingService.swiftindex 9c6a76dc0d..231f8c6403 100644--- a/mobile/native/apple/apps/cast/Cast/Services/CastPairingService.swift+++ b/mobile/native/apple/apps/cast/Cast/Services/CastPairingService.swift@@ -159,7 +159,6 @@ class RealCastPairingService {}- // Decrypt the payload using our private keylet payload = try await decryptPayload(encryptedData: encryptedData,publicKey: device.publicKey,diff --git a/mobile/native/apple/apps/cast/Cast/Services/FileCache.swift b/mobile/native/apple/apps/cast/Cast/Services/FileCache.swiftindex 98f52a0d65..a108fb2046 100644--- a/mobile/native/apple/apps/cast/Cast/Services/FileCache.swift+++ b/mobile/native/apple/apps/cast/Cast/Services/FileCache.swift@@ -15,7 +15,6 @@ actor ThreadSafeFileCache {self.maxBytes = maxBytesself.shrinkTargetBytes = shrinkTargetBytes- // Create persistent cache directorylet documentsPath = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!self.cacheDirectory = documentsPath.appendingPathComponent("EnteFileCache")self.metadataURL = cacheDirectory.appendingPathComponent("cache_metadata.json")@@ -23,17 +22,14 @@ actor ThreadSafeFileCache {// Create cache directory if it doesn't existtry? FileManager.default.createDirectory(at: cacheDirectory, withIntermediateDirectories: true)- // Load existing cache from diskloadCacheFromDisk()}func get(_ fileID: Int) -> Data? {- // Check memory cache firstif let data = cache[fileID] {return data}- // Check disk cachelet fileURL = cacheDirectory.appendingPathComponent("\(fileID).cache")if let data = try? Data(contentsOf: fileURL) {// Load into memory cache for faster future access@@ -49,25 +45,20 @@ actor ThreadSafeFileCache {}func set(_ fileID: Int, data: Data) {- // Remove existing data if presentif let existingData = cache[fileID] {totalBytes -= existingData.countcacheOrder.removeAll { $0 == fileID }}- // Add new data to memory cachecache[fileID] = datacacheOrder.append(fileID)totalBytes += data.count- // Save to disk cachelet fileURL = cacheDirectory.appendingPathComponent("\(fileID).cache")try? data.write(to: fileURL)- // Enforce limitsenforceLimits()- // Save metadatasaveCacheMetadata()print("Cached file \(fileID) content (\(data.count) bytes) - Cache size: \(cache.count) files")@@ -78,11 +69,9 @@ actor ThreadSafeFileCache {totalBytes -= removedData.countcacheOrder.removeAll { $0 == fileID }- // Remove from disk cachelet fileURL = cacheDirectory.appendingPathComponent("\(fileID).cache")try? FileManager.default.removeItem(at: fileURL)- // Save updated metadatasaveCacheMetadata()print("Removed cached content for file \(fileID) (\(removedData.count) bytes)")@@ -95,11 +84,9 @@ actor ThreadSafeFileCache {cacheOrder.removeAll()totalBytes = 0- // Clear disk cachetry? FileManager.default.removeItem(at: cacheDirectory)try? FileManager.default.createDirectory(at: cacheDirectory, withIntermediateDirectories: true)- // Clear metadatatry? FileManager.default.removeItem(at: metadataURL)print("Cleared file content cache (\(clearedCount) files)")@@ -122,7 +109,6 @@ actor ThreadSafeFileCache {if let data = cache.removeValue(forKey: oldest) {removedBytes += data.count- // Remove from disk cachelet fileURL = cacheDirectory.appendingPathComponent("\(oldest).cache")try? FileManager.default.removeItem(at: fileURL)@@ -138,7 +124,6 @@ actor ThreadSafeFileCache {}private func loadCacheFromDisk() {- // Load metadataguard let metadataData = try? Data(contentsOf: metadataURL),let metadata = try? JSONDecoder().decode(CacheMetadata.self, from: metadataData) else {return@@ -146,7 +131,6 @@ actor ThreadSafeFileCache {print("Loading existing cache from disk - \(metadata.fileIDs.count) files")- // Load cache order and calculate total bytesvar loadedBytes = 0var validFileIDs: [Int] = []diff --git a/mobile/native/apple/apps/cast/Cast/Utils/ScreenSaverManager.swift b/mobile/native/apple/apps/cast/Cast/Utils/ScreenSaverManager.swiftindex b58e6102ec..730300028f 100644--- a/mobile/native/apple/apps/cast/Cast/Utils/ScreenSaverManager.swift+++ b/mobile/native/apple/apps/cast/Cast/Utils/ScreenSaverManager.swift@@ -42,7 +42,6 @@ class ScreenSaverManager: ObservableObject {isDisabled = false}- // Cleanup method for app terminationstatic func cleanup() {shared.stopPrevention()}diff --git a/mobile/native/apple/apps/cast/Cast/ViewModels/SlideshowService.swift b/mobile/native/apple/apps/cast/Cast/ViewModels/SlideshowService.swiftindex 6e258ca0ab..c5b5c27eaf 100644--- a/mobile/native/apple/apps/cast/Cast/ViewModels/SlideshowService.swift+++ b/mobile/native/apple/apps/cast/Cast/ViewModels/SlideshowService.swift@@ -190,7 +190,6 @@ class RealSlideshowService: ObservableObject {let validFileIDs = Set(await MainActor.run { allFiles.map { $0.id } })await cleanupExpiredCache(validFileIDs: validFileIDs)- // Initialize slideshow stateawait MainActor.run {self.totalSlides = fileCountself.currentFileIndex = 0@@ -243,10 +242,7 @@ class RealSlideshowService: ObservableObject {error = nil}- // Clear cache to free memory only if explicitly needed- // await clearCache() // Commented out to preserve cache across sessions- // Print final cache statisticslet stats = await getCacheStats()print("Final cache stats: \(stats.count) files, \(stats.totalSize) bytes")@@ -279,7 +275,6 @@ class RealSlideshowService: ObservableObject {livePhotoVideoData = nil}// Don't clear cache automatically - preserve across sessions- // await clearCache() // Only clear if needed for debugging}// MARK: - File List Management@@ -348,7 +343,6 @@ class RealSlideshowService: ObservableObject {}private func fetchFilesBatch(castPayload: CastPayload, sinceTime: Int64) async throws -> (files: [[String: Any]], hasMore: Bool, latestUpdateTime: Int64) {- // Use the collection ID and sinceTime in the API calllet url = URL(string: "\(baseURL)/cast/diff?collectionID=\(castPayload.collectionID)&sinceTime=\(sinceTime)")!@@ -441,7 +435,6 @@ class RealSlideshowService: ObservableObject {currentFileIndex = 0 // Wrap around to beginning}- // Remove from cachesprefetchCache.removeValue(forKey: id)await removeCachedFileContent(fileID: id)@@ -567,7 +560,6 @@ class RealSlideshowService: ObservableObject {return}- // Load from networkdo {let file = allFiles[currentFileIndex]print("Loading file \(file.id): \(file.title) at index \(currentFileIndex)")@@ -580,7 +572,6 @@ class RealSlideshowService: ObservableObject {print("Successfully loaded file \(file.id): \(file.title) (\(decryptedData.count) bytes)")- // Cache the dataprefetchCache[currentFileIndex] = decryptedDataawait updateCurrentSlide(with: decryptedData, file: file)@@ -723,7 +714,6 @@ class RealSlideshowService: ObservableObject {private func skipToNextSlide() async {guard !allFiles.isEmpty else { return }- // Move to next slidecurrentFileIndex = (currentFileIndex + 1) % allFiles.count// If we've gone through all files and still have errors, stop the slideshow@@ -941,7 +931,7 @@ class RealSlideshowService: ObservableObject {isHandlingAuthExpiry = true- // CRITICAL: Stop screen saver prevention immediately before any UI transitions+ // Stop screen saver prevention immediately before any UI transitionsScreenSaverManager.allowScreenSaver()// Stop all ongoing operationsdiff --git a/mobile/native/apple/apps/cast/Cast/Views/SlideshowView.swift b/mobile/native/apple/apps/cast/Cast/Views/SlideshowView.swiftindex 493ed6bd03..d7a34e16c6 100644--- a/mobile/native/apple/apps/cast/Cast/Views/SlideshowView.swift+++ b/mobile/native/apple/apps/cast/Cast/Views/SlideshowView.swift@@ -6,8 +6,7 @@ struct SlideshowView: View {let videoData: Data?let isVideo: Bool@ObservedObject var slideshowService: RealSlideshowService-- // Computed property to determine if current file is a live photo+private var isLivePhoto: Bool {slideshowService.currentFile?.isLivePhoto ?? false}@@ -47,7 +46,7 @@ struct SlideshowView: View {return GeometryReader { geometry inZStack {- // Background layer - FIXED VERSION+ // Background layerif let uiImage = mainUIImage {Image(uiImage: uiImage).resizable()@@ -185,7 +184,7 @@ struct SlideshowView: View {// Backup screen saver prevention at view levelScreenSaverManager.preventScreenSaver()- // CRITICAL FIX: Process initial image data if present and not already processed+ // Process initial image data if present and not already processed// This handles the case where SlideshowView is created with imageData already populated// (e.g., when transitioning from .connecting to .slideshow state)// Without this, onChange won't fire and the image won't displaydiff --git a/mobile/native/apple/apps/cast/Cast/Views/VideoPlayerView.swift b/mobile/native/apple/apps/cast/Cast/Views/VideoPlayerView.swiftindex 5bb4561250..b8c07cb2d3 100644--- a/mobile/native/apple/apps/cast/Cast/Views/VideoPlayerView.swift+++ b/mobile/native/apple/apps/cast/Cast/Views/VideoPlayerView.swift@@ -56,17 +56,13 @@ struct VideoPlayerView: View {private func setupVideoPlayer() {Task {do {- // Extract file extension from suggested filenamelet suggestedExtension = suggestedFilename?.components(separatedBy: ".").last?.lowercased()- // Create temporary file for video data with proper extensionlet tempURL = try await createTemporaryVideoFile(from: videoData, suggestedExtension: suggestedExtension)await MainActor.run {- // Validate that the video file can be playedlet asset = AVURLAsset(url: tempURL)- // Check if the asset is playableTask {let isPlayable = try await asset.load(.isPlayable)let hasVideoTracks = try await !asset.loadTracks(withMediaType: .video).isEmpty@@ -84,7 +80,6 @@ struct VideoPlayerView: View {setupPlayer()} else {- // Try fallback with different extensionself.tryVideoFallback(originalURL: tempURL)}}@@ -93,7 +88,6 @@ struct VideoPlayerView: View {} catch {print("Failed to setup video player: \(error)")await MainActor.run {- // Show error stateself.showErrorState()}}@@ -166,10 +160,8 @@ struct VideoPlayerView: View {print("Failed to set audio session: \(error)")}- // Add observerssetupPlayerObservers()- // Start playingplayer.play()isPlaying = true}@@ -188,7 +180,6 @@ struct VideoPlayerView: View {player.play()}- // Add observer for player status changesNotificationCenter.default.addObserver(forName: .AVPlayerItemFailedToPlayToEndTime,object: currentItem,@@ -289,13 +280,11 @@ struct VideoPlayerView: View {// KVO observer removal no longer needed as we use modern async/await approach- // Remove all notification observersNotificationCenter.default.removeObserver(self, name: .AVPlayerItemDidPlayToEndTime, object: nil)NotificationCenter.default.removeObserver(self, name: .AVPlayerItemFailedToPlayToEndTime, object: nil)NotificationCenter.default.removeObserver(self, name: UIApplication.willResignActiveNotification, object: nil)NotificationCenter.default.removeObserver(self, name: UIApplication.didBecomeActiveNotification, object: nil)- // Deactivate audio sessiondo {try AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)} catch {@@ -309,7 +298,6 @@ struct VideoPlayerView: View {}#Preview {- // Create mock video data for previewlet mockData = Data()VideoPlayerView(videoData: mockData, suggestedFilename: "sample_video.mp4")}