mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-26 11:30:50 +02:00
67df1a3e95
Merge commit 'af0b6d4be985d9f26e5111d3fa01389c7321949f' into feature/7276_FOSS_Merge_1_27_11 # Conflicts: # Config/AppVersion.xcconfig # Gemfile.lock # IDETemplateMacros.plist # Podfile # Podfile.lock # README.md # Riot/Modules/Authentication/AuthenticationCoordinator.swift # Riot/Modules/Room/CellData/RoomBubbleCellData.m # Riot/target.yml # RiotNSE/NotificationService.swift # RiotSwiftUI/Modules/Authentication/ServerSelection/AuthenticationServerSelectionModels.swift # RiotSwiftUI/Modules/Authentication/ServerSelection/AuthenticationServerSelectionViewModel.swift # RiotSwiftUI/Modules/Authentication/ServerSelection/Coordinator/AuthenticationServerSelectionCoordinator.swift # RiotSwiftUI/Modules/Authentication/ServerSelection/View/AuthenticationServerSelectionScreen.swift # RiotSwiftUI/Modules/Room/CompletionSuggestion/Service/CompletionSuggestionService.swift # fastlane/Fastfile
68 lines
2.7 KiB
Swift
68 lines
2.7 KiB
Swift
//
|
|
// Copyright 2022-2024 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
// bwi: we use an additional section and have specific settings we want to apply on first start of the app
|
|
|
|
@objcMembers
|
|
class AllChatsLayoutSettings: NSObject, NSCoding {
|
|
|
|
fileprivate enum Constants {
|
|
static let sectionsKey = "sections"
|
|
static let filtersKey = "filters"
|
|
static let sortingKey = "sorting"
|
|
}
|
|
|
|
let sections: AllChatsLayoutSectionType
|
|
let filters: AllChatsLayoutFilterType
|
|
let sorting: AllChatsLayoutSortingType
|
|
|
|
init(sections: AllChatsLayoutSectionType = [],
|
|
filters: AllChatsLayoutFilterType = [],
|
|
sorting: AllChatsLayoutSortingType = .activity) {
|
|
if !UserDefaults.standard.bool(forKey: "FirstStartWithNewSettings") {
|
|
if PersonalNotesSettings().personalNotesVisible && BWIBuildSettings.shared.bwiPersonalNotesRoom {
|
|
self.sections = [.bwiPersonalNotes]
|
|
} else {
|
|
self.sections = []
|
|
}
|
|
self.filters = [.unreads, .favourites, .people]
|
|
self.sorting = .activity
|
|
UserDefaults.standard.set(true, forKey: "FirstStartWithNewSettings")
|
|
} else {
|
|
self.sections = sections
|
|
self.filters = filters
|
|
self.sorting = sorting
|
|
}
|
|
}
|
|
|
|
func encode(with coder: NSCoder) {
|
|
coder.encode(Int(sections.rawValue), forKey: Constants.sectionsKey)
|
|
coder.encode(Int(filters.rawValue), forKey: Constants.filtersKey)
|
|
coder.encode(Int(sorting.rawValue), forKey: Constants.sortingKey)
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
// bwi: there are cases when only init with coder is called, so use our first start settings here, too
|
|
if !UserDefaults.standard.bool(forKey: "FirstStartWithNewSettings") {
|
|
if PersonalNotesSettings().personalNotesVisible && BWIBuildSettings.shared.bwiPersonalNotesRoom {
|
|
self.sections = [.bwiPersonalNotes]
|
|
} else {
|
|
self.sections = []
|
|
}
|
|
self.filters = [.unreads, .favourites, .people]
|
|
self.sorting = .activity
|
|
UserDefaults.standard.set(true, forKey: "FirstStartWithNewSettings")
|
|
} else {
|
|
self.sections = AllChatsLayoutSectionType(rawValue: UInt(coder.decodeInteger(forKey: Constants.sectionsKey)))
|
|
self.filters = AllChatsLayoutFilterType(rawValue: UInt(coder.decodeInteger(forKey: Constants.filtersKey)))
|
|
self.sorting = AllChatsLayoutSortingType(rawValue: UInt(coder.decodeInteger(forKey: Constants.sortingKey))) ?? .activity
|
|
}
|
|
}
|
|
}
|