Source code for the WriteFreely SwiftUI app for iOS, iPadOS, and macOS
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

WriteFreely_MultiPlatformApp.swift 7.7 KiB

pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
Fix bad merges (#215) * 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 commit 2017a5b43768638089c24cc6ae5193d9342d528d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun Jul 24 06:22:29 2022 -0400 Clean up todo comment commit 669e07ecd9411eb1de3832514158f025655de1d7 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 commit b93e0c3547e23db53e464a57e2d8df469ae319b2 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 12:07:38 2022 -0400 Refactor class to use protocol commit 9b2572ba41544870ac55a6dfbbe72c808a3f54ba Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 11:17:44 2022 -0400 Refactor logging into reuseable methods commit efe173cfca150e11f9fb3bf874f74602796277a3 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri Jun 24 08:40:10 2022 -0400 Update crash alert copy and navigate to help forum commit 5a1b40033345d216669c6f4b58ba4c28bc90b461 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 18 08:53:25 2022 -0400 Log fatal crashes and present alert on next launch commit f1b0a20643cb250b943ddc34ede6ae183ded8417 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 commit 7475b577726faffec856dbdac4c69ed79501b972. commit 7475b577726faffec856dbdac4c69ed79501b972 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 commit a43bd801a8c8a350b488e05300fc9fb93a41af7a Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:35:40 2022 -0400 Add error handling to Mac app commit a315b0955351e326d1244205e6d879750c1c7543 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 06:51:40 2022 -0400 Cleanup commit 7863c2ba084332a9bae6b3a3a6008e83bd11638f Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 09:23:16 2022 -0400 Add error handling to post editor commit 2eba4c5c0483b8779068c52e9e6536b121e59d58 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 07:22:27 2022 -0400 Remove commented-out code commit 230f7a10762266f843b55279695a82d26d062e39 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 07:17:33 2022 -0400 Delete CollectionListModel in favour of FetchRequest in CollectionListView commit fd37a163b9ac3ec4f710e7847b81a7fb83112d3d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:36:43 2022 -0400 Revert "Add error handling to Mac app" This reverts commit b1a8b8b29c7a745ea9733ed0d7266c775b534b47. commit b1a8b8b29c7a745ea9733ed0d7266c775b534b47 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:23:41 2022 -0400 Add error handling to Mac app commit 15f84b04c026749f88404a099df3fe840e2a13a0 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 commit c5b611b39e16bd339282310ab3a65fdafa98e939 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. commit b017e21e066dbcf86a3166fc06d19222047b78b9 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 23 15:52:20 2022 -0400 Handle purging post errors commit 11d2e41ab5d58c405160b81dcdd8597d1e2c552c Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 23 15:12:33 2022 -0400 Add default values for some error strings commit dfb3a08608ed8ec2e2e62ad3010c9d2a67691e51 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:44:13 2022 -0400 Move User Defaults errors to ErrorConstants file commit 223ebf5b7cc1e34e98cc65b980673cbfdbbe527c Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:33:32 2022 -0400 Set current error on API call handlers commit faa557c2b48e3998ace6745a0b1e035ccc320a40 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:01:11 2022 -0400 Set current error on API call failures commit a3b805a31907fe045f47f41da54a1169df653834 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 07:20:47 2022 -0400 Add error handling to top-level content view commit 3a53bec1845d25853bae6c05fe858fcaa195c7eb Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 9 08:55:43 2022 -0400 Clean up WriteFreelyModel’s published vars commit aefcd0d7994393be7cafbde556cda29b8dad423d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 10:18:21 2022 -0400 Fix for temporary debugging commit bf3573895726bfc69cde3fc44960b5d81d29a473 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 09:17:05 2022 -0400 Handle errors on logout commit 01ba57ae759c87a6ac40050f39bfa9e85e46c103 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 09:16:46 2022 -0400 Move Account-related error handling up the hierarchy commit 11200a01a0cf2ad453a7a2f6d4004e129d8d2ca6 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 commit 91e28522437f54f00b4b4854458ce5137721a481 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 06:50:34 2022 -0400 Bump writefreely-swift package minimum version
pirms 1 gada
pirms 3 gadiem
Fix bad merges (#215) * 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 commit 2017a5b43768638089c24cc6ae5193d9342d528d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun Jul 24 06:22:29 2022 -0400 Clean up todo comment commit 669e07ecd9411eb1de3832514158f025655de1d7 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 commit b93e0c3547e23db53e464a57e2d8df469ae319b2 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 12:07:38 2022 -0400 Refactor class to use protocol commit 9b2572ba41544870ac55a6dfbbe72c808a3f54ba Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 11:17:44 2022 -0400 Refactor logging into reuseable methods commit efe173cfca150e11f9fb3bf874f74602796277a3 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri Jun 24 08:40:10 2022 -0400 Update crash alert copy and navigate to help forum commit 5a1b40033345d216669c6f4b58ba4c28bc90b461 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 18 08:53:25 2022 -0400 Log fatal crashes and present alert on next launch commit f1b0a20643cb250b943ddc34ede6ae183ded8417 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 commit 7475b577726faffec856dbdac4c69ed79501b972. commit 7475b577726faffec856dbdac4c69ed79501b972 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 commit a43bd801a8c8a350b488e05300fc9fb93a41af7a Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:35:40 2022 -0400 Add error handling to Mac app commit a315b0955351e326d1244205e6d879750c1c7543 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 06:51:40 2022 -0400 Cleanup commit 7863c2ba084332a9bae6b3a3a6008e83bd11638f Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 09:23:16 2022 -0400 Add error handling to post editor commit 2eba4c5c0483b8779068c52e9e6536b121e59d58 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 07:22:27 2022 -0400 Remove commented-out code commit 230f7a10762266f843b55279695a82d26d062e39 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 07:17:33 2022 -0400 Delete CollectionListModel in favour of FetchRequest in CollectionListView commit fd37a163b9ac3ec4f710e7847b81a7fb83112d3d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:36:43 2022 -0400 Revert "Add error handling to Mac app" This reverts commit b1a8b8b29c7a745ea9733ed0d7266c775b534b47. commit b1a8b8b29c7a745ea9733ed0d7266c775b534b47 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:23:41 2022 -0400 Add error handling to Mac app commit 15f84b04c026749f88404a099df3fe840e2a13a0 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 commit c5b611b39e16bd339282310ab3a65fdafa98e939 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. commit b017e21e066dbcf86a3166fc06d19222047b78b9 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 23 15:52:20 2022 -0400 Handle purging post errors commit 11d2e41ab5d58c405160b81dcdd8597d1e2c552c Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 23 15:12:33 2022 -0400 Add default values for some error strings commit dfb3a08608ed8ec2e2e62ad3010c9d2a67691e51 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:44:13 2022 -0400 Move User Defaults errors to ErrorConstants file commit 223ebf5b7cc1e34e98cc65b980673cbfdbbe527c Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:33:32 2022 -0400 Set current error on API call handlers commit faa557c2b48e3998ace6745a0b1e035ccc320a40 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:01:11 2022 -0400 Set current error on API call failures commit a3b805a31907fe045f47f41da54a1169df653834 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 07:20:47 2022 -0400 Add error handling to top-level content view commit 3a53bec1845d25853bae6c05fe858fcaa195c7eb Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 9 08:55:43 2022 -0400 Clean up WriteFreelyModel’s published vars commit aefcd0d7994393be7cafbde556cda29b8dad423d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 10:18:21 2022 -0400 Fix for temporary debugging commit bf3573895726bfc69cde3fc44960b5d81d29a473 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 09:17:05 2022 -0400 Handle errors on logout commit 01ba57ae759c87a6ac40050f39bfa9e85e46c103 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 09:16:46 2022 -0400 Move Account-related error handling up the hierarchy commit 11200a01a0cf2ad453a7a2f6d4004e129d8d2ca6 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 commit 91e28522437f54f00b4b4854458ce5137721a481 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 06:50:34 2022 -0400 Bump writefreely-swift package minimum version
pirms 1 gada
pirms 3 gadiem
pirms 3 gadiem
Fix bad merges (#215) * 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 commit 2017a5b43768638089c24cc6ae5193d9342d528d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun Jul 24 06:22:29 2022 -0400 Clean up todo comment commit 669e07ecd9411eb1de3832514158f025655de1d7 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 commit b93e0c3547e23db53e464a57e2d8df469ae319b2 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 12:07:38 2022 -0400 Refactor class to use protocol commit 9b2572ba41544870ac55a6dfbbe72c808a3f54ba Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 11:17:44 2022 -0400 Refactor logging into reuseable methods commit efe173cfca150e11f9fb3bf874f74602796277a3 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri Jun 24 08:40:10 2022 -0400 Update crash alert copy and navigate to help forum commit 5a1b40033345d216669c6f4b58ba4c28bc90b461 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 18 08:53:25 2022 -0400 Log fatal crashes and present alert on next launch commit f1b0a20643cb250b943ddc34ede6ae183ded8417 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 commit 7475b577726faffec856dbdac4c69ed79501b972. commit 7475b577726faffec856dbdac4c69ed79501b972 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 commit a43bd801a8c8a350b488e05300fc9fb93a41af7a Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:35:40 2022 -0400 Add error handling to Mac app commit a315b0955351e326d1244205e6d879750c1c7543 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 06:51:40 2022 -0400 Cleanup commit 7863c2ba084332a9bae6b3a3a6008e83bd11638f Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 09:23:16 2022 -0400 Add error handling to post editor commit 2eba4c5c0483b8779068c52e9e6536b121e59d58 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 07:22:27 2022 -0400 Remove commented-out code commit 230f7a10762266f843b55279695a82d26d062e39 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 07:17:33 2022 -0400 Delete CollectionListModel in favour of FetchRequest in CollectionListView commit fd37a163b9ac3ec4f710e7847b81a7fb83112d3d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:36:43 2022 -0400 Revert "Add error handling to Mac app" This reverts commit b1a8b8b29c7a745ea9733ed0d7266c775b534b47. commit b1a8b8b29c7a745ea9733ed0d7266c775b534b47 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:23:41 2022 -0400 Add error handling to Mac app commit 15f84b04c026749f88404a099df3fe840e2a13a0 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 commit c5b611b39e16bd339282310ab3a65fdafa98e939 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. commit b017e21e066dbcf86a3166fc06d19222047b78b9 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 23 15:52:20 2022 -0400 Handle purging post errors commit 11d2e41ab5d58c405160b81dcdd8597d1e2c552c Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 23 15:12:33 2022 -0400 Add default values for some error strings commit dfb3a08608ed8ec2e2e62ad3010c9d2a67691e51 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:44:13 2022 -0400 Move User Defaults errors to ErrorConstants file commit 223ebf5b7cc1e34e98cc65b980673cbfdbbe527c Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:33:32 2022 -0400 Set current error on API call handlers commit faa557c2b48e3998ace6745a0b1e035ccc320a40 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:01:11 2022 -0400 Set current error on API call failures commit a3b805a31907fe045f47f41da54a1169df653834 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 07:20:47 2022 -0400 Add error handling to top-level content view commit 3a53bec1845d25853bae6c05fe858fcaa195c7eb Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 9 08:55:43 2022 -0400 Clean up WriteFreelyModel’s published vars commit aefcd0d7994393be7cafbde556cda29b8dad423d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 10:18:21 2022 -0400 Fix for temporary debugging commit bf3573895726bfc69cde3fc44960b5d81d29a473 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 09:17:05 2022 -0400 Handle errors on logout commit 01ba57ae759c87a6ac40050f39bfa9e85e46c103 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 09:16:46 2022 -0400 Move Account-related error handling up the hierarchy commit 11200a01a0cf2ad453a7a2f6d4004e129d8d2ca6 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 commit 91e28522437f54f00b4b4854458ce5137721a481 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 06:50:34 2022 -0400 Bump writefreely-swift package minimum version
pirms 1 gada
Fix bad merges (#215) * 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 commit 2017a5b43768638089c24cc6ae5193d9342d528d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun Jul 24 06:22:29 2022 -0400 Clean up todo comment commit 669e07ecd9411eb1de3832514158f025655de1d7 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 commit b93e0c3547e23db53e464a57e2d8df469ae319b2 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 12:07:38 2022 -0400 Refactor class to use protocol commit 9b2572ba41544870ac55a6dfbbe72c808a3f54ba Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 25 11:17:44 2022 -0400 Refactor logging into reuseable methods commit efe173cfca150e11f9fb3bf874f74602796277a3 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri Jun 24 08:40:10 2022 -0400 Update crash alert copy and navigate to help forum commit 5a1b40033345d216669c6f4b58ba4c28bc90b461 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat Jun 18 08:53:25 2022 -0400 Log fatal crashes and present alert on next launch commit f1b0a20643cb250b943ddc34ede6ae183ded8417 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 commit 7475b577726faffec856dbdac4c69ed79501b972. commit 7475b577726faffec856dbdac4c69ed79501b972 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 commit a43bd801a8c8a350b488e05300fc9fb93a41af7a Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:35:40 2022 -0400 Add error handling to Mac app commit a315b0955351e326d1244205e6d879750c1c7543 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 06:51:40 2022 -0400 Cleanup commit 7863c2ba084332a9bae6b3a3a6008e83bd11638f Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 09:23:16 2022 -0400 Add error handling to post editor commit 2eba4c5c0483b8779068c52e9e6536b121e59d58 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 07:22:27 2022 -0400 Remove commented-out code commit 230f7a10762266f843b55279695a82d26d062e39 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 07:17:33 2022 -0400 Delete CollectionListModel in favour of FetchRequest in CollectionListView commit fd37a163b9ac3ec4f710e7847b81a7fb83112d3d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:36:43 2022 -0400 Revert "Add error handling to Mac app" This reverts commit b1a8b8b29c7a745ea9733ed0d7266c775b534b47. commit b1a8b8b29c7a745ea9733ed0d7266c775b534b47 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Tue May 31 07:23:41 2022 -0400 Add error handling to Mac app commit 15f84b04c026749f88404a099df3fe840e2a13a0 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 commit c5b611b39e16bd339282310ab3a65fdafa98e939 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. commit b017e21e066dbcf86a3166fc06d19222047b78b9 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 23 15:52:20 2022 -0400 Handle purging post errors commit 11d2e41ab5d58c405160b81dcdd8597d1e2c552c Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 23 15:12:33 2022 -0400 Add default values for some error strings commit dfb3a08608ed8ec2e2e62ad3010c9d2a67691e51 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:44:13 2022 -0400 Move User Defaults errors to ErrorConstants file commit 223ebf5b7cc1e34e98cc65b980673cbfdbbe527c Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:33:32 2022 -0400 Set current error on API call handlers commit faa557c2b48e3998ace6745a0b1e035ccc320a40 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 08:01:11 2022 -0400 Set current error on API call failures commit a3b805a31907fe045f47f41da54a1169df653834 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Fri May 13 07:20:47 2022 -0400 Add error handling to top-level content view commit 3a53bec1845d25853bae6c05fe858fcaa195c7eb Author: Angelo Stavrow <contact@angelostavrow.com> Date: Mon May 9 08:55:43 2022 -0400 Clean up WriteFreelyModel’s published vars commit aefcd0d7994393be7cafbde556cda29b8dad423d Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 10:18:21 2022 -0400 Fix for temporary debugging commit bf3573895726bfc69cde3fc44960b5d81d29a473 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 09:17:05 2022 -0400 Handle errors on logout commit 01ba57ae759c87a6ac40050f39bfa9e85e46c103 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sun May 8 09:16:46 2022 -0400 Move Account-related error handling up the hierarchy commit 11200a01a0cf2ad453a7a2f6d4004e129d8d2ca6 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 commit 91e28522437f54f00b4b4854458ce5137721a481 Author: Angelo Stavrow <contact@angelostavrow.com> Date: Sat May 28 06:50:34 2022 -0400 Bump writefreely-swift package minimum version
pirms 1 gada
pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. import SwiftUI
  2. #if os(macOS)
  3. import Sparkle
  4. #endif
  5. @main
  6. struct CheckForDebugModifier {
  7. static func main() {
  8. #if os(macOS)
  9. if NSEvent.modifierFlags.contains(.shift) {
  10. // Clear the launch-to-last-draft values to load a new draft.
  11. UserDefaults.shared.setValue(false, forKey: WFDefaults.showAllPostsFlag)
  12. UserDefaults.shared.setValue(nil, forKey: WFDefaults.selectedCollectionURL)
  13. UserDefaults.shared.setValue(nil, forKey: WFDefaults.lastDraftURL)
  14. } else {
  15. // No-op
  16. }
  17. #endif
  18. WriteFreely_MultiPlatformApp.main()
  19. }
  20. }
  21. struct WriteFreely_MultiPlatformApp: App {
  22. @StateObject private var model = WriteFreelyModel.shared
  23. private let logger = Logging(for: String(describing: WriteFreely_MultiPlatformApp.self))
  24. #if os(macOS)
  25. @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
  26. @StateObject var updaterViewModel = MacUpdatesViewModel()
  27. @State private var selectedTab = 0
  28. #endif
  29. @State private var didCrash = UserDefaults.shared.bool(forKey: WFDefaults.didHaveFatalError)
  30. var body: some Scene {
  31. WindowGroup {
  32. ContentView()
  33. .onAppear(perform: {
  34. if model.editor.showAllPostsFlag {
  35. DispatchQueue.main.async {
  36. self.model.selectedCollection = nil
  37. self.model.showAllPosts = true
  38. showLastDraftOrCreateNewLocalPost()
  39. }
  40. } else {
  41. DispatchQueue.main.async {
  42. self.model.selectedCollection = model.editor.fetchSelectedCollectionFromAppStorage()
  43. self.model.showAllPosts = false
  44. showLastDraftOrCreateNewLocalPost()
  45. }
  46. }
  47. })
  48. .alert(isPresented: $didCrash) {
  49. var helpMsg = "Alert the humans by sharing what happened on the help forum."
  50. if let errorMsg = UserDefaults.shared.object(forKey: WFDefaults.fatalErrorDescription) as? String {
  51. helpMsg.append("\n\n\(errorMsg)")
  52. }
  53. return Alert(
  54. title: Text("Crash Detected"),
  55. message: Text(helpMsg),
  56. primaryButton: .default(
  57. Text("Let us know"), action: didPressCrashAlertButton
  58. ),
  59. secondaryButton: .cancel(
  60. Text("Dismiss"),
  61. action: resetCrashFlags
  62. )
  63. )
  64. }
  65. .onAppear {
  66. if #available(iOS 15, *) {
  67. if didCrash { generateCrashLogPost() }
  68. }
  69. }
  70. .withErrorHandling()
  71. .environmentObject(model)
  72. .environment(\.managedObjectContext, LocalStorageManager.standard.container.viewContext)
  73. // .preferredColorScheme(preferences.selectedColorScheme) // See PreferencesModel for info.
  74. }
  75. .commands {
  76. #if os(macOS)
  77. CommandGroup(after: .appInfo) {
  78. CheckForUpdatesView(updaterViewModel: updaterViewModel)
  79. }
  80. #endif
  81. CommandGroup(replacing: .newItem, addition: {
  82. Button("New Post") {
  83. createNewLocalPost()
  84. }
  85. .keyboardShortcut("n", modifiers: [.command])
  86. })
  87. CommandGroup(after: .newItem) {
  88. Button("Refresh Posts") {
  89. DispatchQueue.main.async {
  90. model.fetchUserCollections()
  91. model.fetchUserPosts()
  92. }
  93. }
  94. .disabled(!model.account.isLoggedIn)
  95. .keyboardShortcut("r", modifiers: [.command])
  96. }
  97. SidebarCommands()
  98. #if os(macOS)
  99. PostCommands(model: model)
  100. HelpCommands(model: model)
  101. #endif
  102. ToolbarCommands()
  103. TextEditingCommands()
  104. }
  105. #if os(macOS)
  106. Settings {
  107. TabView(selection: $selectedTab) {
  108. MacAccountView()
  109. .environmentObject(model)
  110. .tabItem {
  111. Image(systemName: "person.crop.circle")
  112. Text("Account")
  113. }
  114. .tag(0)
  115. MacPreferencesView(preferences: model.preferences)
  116. .tabItem {
  117. Image(systemName: "gear")
  118. Text("Preferences")
  119. }
  120. .tag(1)
  121. MacUpdatesView(updaterViewModel: updaterViewModel)
  122. .tabItem {
  123. Image(systemName: "arrow.down.circle")
  124. Text("Updates")
  125. }
  126. .tag(2)
  127. }
  128. .environmentObject(model)
  129. .withErrorHandling()
  130. .frame(minWidth: 500, maxWidth: 500, minHeight: 200)
  131. .padding()
  132. // .preferredColorScheme(preferences.selectedColorScheme) // See PreferencesModel for info.
  133. }
  134. #endif
  135. }
  136. private func showLastDraftOrCreateNewLocalPost() {
  137. if model.editor.lastDraftURL != nil {
  138. DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
  139. self.model.selectedPost = model.editor.fetchLastDraftFromAppStorage()
  140. }
  141. } else {
  142. createNewLocalPost()
  143. }
  144. }
  145. private func createNewLocalPost() {
  146. withAnimation {
  147. // Un-set the currently selected post
  148. self.model.selectedPost = nil
  149. }
  150. // Create the new-post managed object
  151. let managedPost = model.editor.generateNewLocalPost(withFont: model.preferences.font)
  152. withAnimation {
  153. // Set it as the selectedPost
  154. DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
  155. self.model.selectedPost = managedPost
  156. }
  157. }
  158. }
  159. @available(iOS 15, *)
  160. private func generateCrashLogPost() {
  161. logger.log("Generating local log post...")
  162. DispatchQueue.main.asyncAfter(deadline: .now()) {
  163. // Unset selected post and collection and navigate to local drafts.
  164. self.model.selectedPost = nil
  165. self.model.selectedCollection = nil
  166. self.model.showAllPosts = false
  167. // Create the new log post.
  168. let newLogPost = model.editor.generateNewLocalPost(withFont: 2)
  169. newLogPost.title = "Logs For Support"
  170. var postBody: [String] = [
  171. "WriteFreely-Multiplatform v\(Bundle.main.appMarketingVersion) (\(Bundle.main.appBuildVersion))",
  172. "Generated \(Date())",
  173. ""
  174. ]
  175. postBody.append(contentsOf: logger.fetchLogs())
  176. newLogPost.body = postBody.joined(separator: "\n")
  177. self.model.selectedPost = newLogPost
  178. }
  179. logger.log("Generated local log post.")
  180. }
  181. private func resetCrashFlags() {
  182. UserDefaults.shared.set(false, forKey: WFDefaults.didHaveFatalError)
  183. UserDefaults.shared.removeObject(forKey: WFDefaults.fatalErrorDescription)
  184. }
  185. private func didPressCrashAlertButton() {
  186. resetCrashFlags()
  187. #if os(macOS)
  188. NSWorkspace().open(model.helpURL)
  189. #else
  190. UIApplication.shared.open(model.helpURL)
  191. #endif
  192. }
  193. }