mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
dbcb18b1df
* Alert on error: shared code commit 00e6fabe1dad243eb49d5ffdd9695bda287b8b53 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Thu Jul 28 07:16:22 2022 -0400 Replace CollectionListModel with FetchRequest in CollectionListView commit d54b9471ba9da5d22c904bbb38a555529d3c15a5 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Thu Jul 28 07:13:13 2022 -0400 Add error handling to iOS post editor commit b48fde47147572fe78379c2bd76430f474ac4822 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Wed Jul 27 12:13:06 2022 -0400 Add error handling to macOS commit 695da810854414620035005b83d9c366669f96ff Author: Angelo Stavrow <contact@angelostavrow.com> Date: Wed Jul 27 12:00:34 2022 -0400 Log fatal errors and present alert on next launch commit2017a5b437
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun Jul 24 06:22:29 2022 -0400 Clean up todo comment commit669e07ecd9
Merge:efe173c
b93e0c3
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 12:08:17 2022 -0400 Merge branch 'show-downloadable-logs' into log-localstore-errors commitb93e0c3547
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 12:07:38 2022 -0400 Refactor class to use protocol commit9b2572ba41
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 11:17:44 2022 -0400 Refactor logging into reuseable methods commitefe173cfca
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri Jun 24 08:40:10 2022 -0400 Update crash alert copy and navigate to help forum commit5a1b400333
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 18 08:53:25 2022 -0400 Log fatal crashes and present alert on next launch commitf1b0a20643
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Wed Jul 27 11:42:05 2022 -0400 Revert "Log fatal errors and present alert on next launch (#212)" This reverts commit7475b57772
. commit7475b57772
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Wed Jul 27 09:47:06 2022 -0400 Log fatal errors and present alert on next launch (#212) * Log fatal crashes and present alert on next launch * Update crash alert copy and navigate to help forum * Refactor logging into reuseable methods * Refactor class to use protocol * Clean up todo comment commita43bd801a8
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:35:40 2022 -0400 Add error handling to Mac app commita315b09553
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 06:51:40 2022 -0400 Cleanup commit7863c2ba08
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 09:23:16 2022 -0400 Add error handling to post editor commit2eba4c5c04
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 07:22:27 2022 -0400 Remove commented-out code commit230f7a1076
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 07:17:33 2022 -0400 Delete CollectionListModel in favour of FetchRequest in CollectionListView commitfd37a163b9
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:36:43 2022 -0400 Revert "Add error handling to Mac app" This reverts commitb1a8b8b29c
. commitb1a8b8b29c
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:23:41 2022 -0400 Add error handling to Mac app commit15f84b04c0
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Thu May 26 08:08:12 2022 -0400 Handle errors in (most) shared code Two outliers to come back to are: - the LocalStoreManager, where we can’t set a current error in the WriteFreelyModel in methods that can’t throw - the CollectionListModel, where the initializer can’t throw because we use it as a property initializer in CollectionListView commitc5b611b39e
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Thu May 26 07:31:11 2022 -0400 Add FIXME to track silent failure on fetching collections As collections are fetched and added to the `list` property in the CollectionListModel’s initializer, it’s tricky to throw an error here: we call it as a property initializer in CollectionListView, which cannot throw. Consider refactoring this logic such that we’re using, for example, a @FetchRequest in CollectionListView instead. commitb017e21e06
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 23 15:52:20 2022 -0400 Handle purging post errors commit11d2e41ab5
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 23 15:12:33 2022 -0400 Add default values for some error strings commitdfb3a08608
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:44:13 2022 -0400 Move User Defaults errors to ErrorConstants file commit223ebf5b7c
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:33:32 2022 -0400 Set current error on API call handlers commitfaa557c2b4
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:01:11 2022 -0400 Set current error on API call failures commita3b805a319
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 07:20:47 2022 -0400 Add error handling to top-level content view commit3a53bec184
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 9 08:55:43 2022 -0400 Clean up WriteFreelyModel’s published vars commitaefcd0d799
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 10:18:21 2022 -0400 Fix for temporary debugging commitbf35738957
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 09:17:05 2022 -0400 Handle errors on logout commit01ba57ae75
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 09:16:46 2022 -0400 Move Account-related error handling up the hierarchy commit11200a01a0
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 1 12:06:36 2022 -0400 Initial work on presenting alert on error * Bump writefreely-swift package minimum version commit91e2852243
Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 06:50:34 2022 -0400 Bump writefreely-swift package minimum version
60 lines
2.2 KiB
Swift
60 lines
2.2 KiB
Swift
import Foundation
|
|
|
|
enum WFDefaults {
|
|
static let isLoggedIn = "isLoggedIn"
|
|
static let showAllPostsFlag = "showAllPostsFlag"
|
|
static let selectedCollectionURL = "selectedCollectionURL"
|
|
static let lastDraftURL = "lastDraftURL"
|
|
static let colorSchemeIntegerKey = "colorSchemeIntegerKey"
|
|
static let defaultFontIntegerKey = "defaultFontIntegerKey"
|
|
static let usernameStringKey = "usernameStringKey"
|
|
static let serverStringKey = "serverStringKey"
|
|
#if os(macOS)
|
|
static let automaticallyChecksForUpdates = "automaticallyChecksForUpdates"
|
|
static let subscribeToBetaUpdates = "subscribeToBetaUpdates"
|
|
#endif
|
|
static let didHaveFatalError = "didHaveFatalError"
|
|
static let fatalErrorDescription = "fatalErrorDescription"
|
|
}
|
|
|
|
extension UserDefaults {
|
|
|
|
private static let appGroupName: String = "group.com.abunchtell.writefreely"
|
|
private static let didMigrateDefaultsToAppGroup: String = "didMigrateDefaultsToAppGroup"
|
|
private static let didRemoveStandardDefaults: String = "didRemoveStandardDefaults"
|
|
|
|
static var shared: UserDefaults {
|
|
if let groupDefaults = UserDefaults(suiteName: UserDefaults.appGroupName),
|
|
groupDefaults.bool(forKey: UserDefaults.didMigrateDefaultsToAppGroup) {
|
|
return groupDefaults
|
|
} else {
|
|
do {
|
|
let groupDefaults = try UserDefaults.standard.migrateDefaultsToAppGroup()
|
|
return groupDefaults
|
|
} catch {
|
|
return UserDefaults.standard
|
|
}
|
|
}
|
|
}
|
|
|
|
private func migrateDefaultsToAppGroup() throws -> UserDefaults {
|
|
let userDefaults = UserDefaults.standard
|
|
let groupDefaults = UserDefaults(suiteName: UserDefaults.appGroupName)
|
|
|
|
if let groupDefaults = groupDefaults {
|
|
if groupDefaults.bool(forKey: UserDefaults.didMigrateDefaultsToAppGroup) {
|
|
return groupDefaults
|
|
}
|
|
|
|
for (key, value) in userDefaults.dictionaryRepresentation() {
|
|
groupDefaults.set(value, forKey: key)
|
|
}
|
|
groupDefaults.set(true, forKey: UserDefaults.didMigrateDefaultsToAppGroup)
|
|
return groupDefaults
|
|
} else {
|
|
throw UserDefaultsError.couldNotMigrateStandardDefaults
|
|
}
|
|
}
|
|
|
|
}
|