Skip to content

Commit

Permalink
Application: Use the plist minVersion to restrict updates
Browse files Browse the repository at this point in the history
It's more reliable to use the plist which contains the min version
to determine if an update notification should be shown.

Signed-off-by: kingbri <[email protected]>
  • Loading branch information
kingbri1 committed Mar 23, 2023
1 parent c719d2c commit ff13884
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Ferrite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
0C03EB72296F619900162E9A /* PluginList+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C03EB70296F619900162E9A /* PluginList+CoreDataProperties.swift */; };
0C0755C6293424A200ECA142 /* DebridLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C0755C5293424A200ECA142 /* DebridLabelView.swift */; };
0C0755C8293425B500ECA142 /* DebridManagerModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C0755C7293425B500ECA142 /* DebridManagerModels.swift */; };
0C0974B029CCAAAF006DE7A3 /* OperatingSystemVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C0974AF29CCAAAF006DE7A3 /* OperatingSystemVersion.swift */; };
0C0D50E5288DFE7F0035ECC8 /* SourceModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C0D50E4288DFE7F0035ECC8 /* SourceModels.swift */; };
0C0D50E7288DFF850035ECC8 /* PluginAggregateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C0D50E6288DFF850035ECC8 /* PluginAggregateView.swift */; };
0C10848B28BD9A38008F0BA6 /* SettingsAppVersionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C10848A28BD9A38008F0BA6 /* SettingsAppVersionView.swift */; };
Expand Down Expand Up @@ -151,6 +152,7 @@
0C03EB70296F619900162E9A /* PluginList+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PluginList+CoreDataProperties.swift"; sourceTree = "<group>"; };
0C0755C5293424A200ECA142 /* DebridLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebridLabelView.swift; sourceTree = "<group>"; };
0C0755C7293425B500ECA142 /* DebridManagerModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebridManagerModels.swift; sourceTree = "<group>"; };
0C0974AF29CCAAAF006DE7A3 /* OperatingSystemVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperatingSystemVersion.swift; sourceTree = "<group>"; };
0C0D50E4288DFE7F0035ECC8 /* SourceModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceModels.swift; sourceTree = "<group>"; };
0C0D50E6288DFF850035ECC8 /* PluginAggregateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PluginAggregateView.swift; sourceTree = "<group>"; };
0C10848A28BD9A38008F0BA6 /* SettingsAppVersionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAppVersionView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -551,6 +553,7 @@
0CA148CB288903F000DE2211 /* Task.swift */,
0C7D11FD28AA03FE00ED92DB /* View.swift */,
0C7ED14228D65518009E29AD /* FileManager.swift */,
0C0974AF29CCAAAF006DE7A3 /* OperatingSystemVersion.swift */,
0C42B5972932F6DD008057A0 /* Set.swift */,
0C7C128528DAA3CD00381CD1 /* URL.swift */,
0C50B7CF299DF63C00A9FA3C /* UIDevice.swift */,
Expand Down Expand Up @@ -868,6 +871,7 @@
0C44E2AD28D51C63007711AE /* BackupManager.swift in Sources */,
0C422E80293542F300486D65 /* PremiumizeModels.swift in Sources */,
0C4CFC4D28970C8B00AD9FAD /* SourceComplexQuery+CoreDataClass.swift in Sources */,
0C0974B029CCAAAF006DE7A3 /* OperatingSystemVersion.swift in Sources */,
0CA148E8288903F000DE2211 /* RealDebridWrapper.swift in Sources */,
0CA148D6288903F000DE2211 /* SettingsView.swift in Sources */,
0C572D4E299403B7003EEC05 /* ViewDidAppear.swift in Sources */,
Expand Down
14 changes: 14 additions & 0 deletions Ferrite/Extensions/OperatingSystemVersion.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// OperatingSystemVersion.swift
// Ferrite
//
// Created by Brian Dashore on 3/23/23.
//

import Foundation

extension OperatingSystemVersion {
func toString() -> String {
return "\(self.majorVersion).\(self.minorVersion).\(self.patchVersion)"
}
}
4 changes: 3 additions & 1 deletion Ferrite/Utils/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public class Application {
let os = "ios"

// Minimum OS version that Ferrite runs on
let minVersion = OperatingSystemVersion(majorVersion: 14, minorVersion: 0, patchVersion: 0)
var minVersion: String {
Bundle.main.object(forInfoDictionaryKey: "MinimumOSVersion") as? String ?? "0.0"
}

// Grabs the current user's OS version
let osVersion: OperatingSystemVersion = ProcessInfo().operatingSystemVersion
Expand Down
4 changes: 3 additions & 1 deletion Ferrite/Views/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct MainView: View {
.backport.onAppear {
if
autoUpdateNotifs,
Application.shared.osVersion.majorVersion >= Application.shared.minVersion.majorVersion
Application.shared.osVersion.toString() >= Application.shared.minVersion
{
// MARK: If scope bar duplication happens, this may be the problem

Expand All @@ -98,6 +98,8 @@ struct MainView: View {
if releaseVersion > Application.shared.appVersion {
releaseVersionString = latestRelease.tagName
releaseUrlString = latestRelease.htmlUrl

logManager.info("Update available to \(releaseVersionString)")
showUpdateAlert.toggle()
}
} catch {
Expand Down

0 comments on commit ff13884

Please sign in to comment.