Fix #457 - Persist entry sorting preferences across app launches (#458)

Changed sorting state from @State to @AppStorage in EntriesView to ensure user preferences are saved to UserDefaults. Also made sorting criteria mutually exclusive for a better UX.
This commit is contained in:
Ben Hughes
2026-02-20 17:19:44 +11:00
committed by GitHub
parent 0c182f2eb1
commit a2f9e8e7a2
2 changed files with 13 additions and 6 deletions
+12 -5
View File
@@ -8,9 +8,9 @@ struct EntriesView: View {
@Environment(WallabagPlusStore.self) private var wallabagPlusStore
@EnvironmentObject var appState: AppState
@StateObject var searchViewModel = SearchViewModel()
@State var entriesSortedById = true
@State var entriesSortedByReadingTime = false
@State var entriesSortedByAscending = false
@AppStorage("entriesSortedById") var entriesSortedById = true
@AppStorage("entriesSortedByReadingTime") var entriesSortedByReadingTime = false
@AppStorage("entriesSortedByAscending") var entriesSortedByAscending = false
@State private var showPaywallWallabagPlus = false
var body: some View {
@@ -26,8 +26,15 @@ struct EntriesView: View {
entriesSortedByAscending: entriesSortedByAscending
)
}
.onChange(of: entriesSortedByReadingTime) { _, _ in
entriesSortedById = false
.onChange(of: entriesSortedById) { _, newValue in
if newValue {
entriesSortedByReadingTime = false
}
}
.onChange(of: entriesSortedByReadingTime) { _, newValue in
if newValue {
entriesSortedById = false
}
}
.toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) {
+1 -1
View File
@@ -1495,7 +1495,7 @@
repositoryURL = "https://github.com/RevenueCat/purchases-ios-spm.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.15.0;
minimumVersion = 5.16.0;
};
};
/* End XCRemoteSwiftPackageReference section */