-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple NTP settings persistence from AppUserDefaults (#3354)
Task/Issue URL: https://app.asana.com/0/72649045549333/1208273840160821/f Tech Design URL: CC: **Description**: Extract NTP data persistence into smaller protocols and use `UserDefaultsWrapper` to implement the actual storing. The change allows for better separation of concerns and potentially storing data in a different way on a case-by-case basis. **Steps to test this PR**: 1. Verify NTP sections and shortcuts settings (order, enabled state) are preserved across app instances. 2. Verify intro message is dismissed after 3 views (it can be set up from Debug menu). **Definition of Done (Internal Only)**: * [ ] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)? --- ###### Internal references: [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943)
- Loading branch information
Showing
18 changed files
with
161 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// NewTabPageIntroDataStoring.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
import Core | ||
|
||
protocol NewTabPageIntroDataStoring: AnyObject { | ||
var newTabPageIntroMessageEnabled: Bool? { get set } | ||
var newTabPageIntroMessageSeenCount: Int { get set } | ||
} | ||
|
||
final class NewTabPageIntroDataUserDefaultsStorage: NewTabPageIntroDataStoring { | ||
@UserDefaultsWrapper(key: .newTabPageIntroMessageEnabled, defaultValue: nil) | ||
var newTabPageIntroMessageEnabled: Bool? | ||
|
||
@UserDefaultsWrapper(key: .newTabPageIntroMessageSeenCount, defaultValue: 0) | ||
var newTabPageIntroMessageSeenCount: Int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// NewTabPageSettingsPersistentStore.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
import Core | ||
|
||
final class NewTabPageShorctutsSettingsStore: NewTabPageSettingsPersistentStore { | ||
@UserDefaultsWrapper(key: .newTabPageShortcutsSettings, defaultValue: nil) | ||
var data: Data? | ||
} | ||
|
||
final class NewTabPageSectionsSettingsStore: NewTabPageSettingsPersistentStore { | ||
@UserDefaultsWrapper(key: .newTabPageSectionsSettings, defaultValue: nil) | ||
var data: Data? | ||
} |
Oops, something went wrong.