Fix crash-on-launch when post list is empty (#241)

* Apply a quarter-second delay to the dispatched call

* Update change log

* Fix nav-back bug when launching to last draft

* Improve keyboard present/dismiss animations

* Update change log and bump build number
This commit is contained in:
Angelo Stavrow 2023-01-15 15:46:16 -05:00 committed by GitHub
parent 52618095f2
commit 040f398b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 11 deletions

View File

@ -46,6 +46,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [Mac] Fixed some build warnings in the project. - [Mac] Fixed some build warnings in the project.
- [Mac] Bumped WriteFreely package to v0.3.6 to handle decoding of fractional seconds in dates. - [Mac] Bumped WriteFreely package to v0.3.6 to handle decoding of fractional seconds in dates.
- [iOS] Fixed a bug where posts were always shown in serif, even if the post was published with another font. - [iOS] Fixed a bug where posts were always shown in serif, even if the post was published with another font.
- [iOS] Restored the new-draft-on-launch feature and resolves crashing bug.
- [iOS] Fixed a bug that would navigate to a post on launch, then immediately navigate back to the post list.
- [iOS] Fixed some animation glitches when presenting and dismissing the keyboard.
## [1.0.14-ios] - 2022-12-18 ## [1.0.14-ios] - 2022-12-18

View File

@ -152,13 +152,13 @@ struct WriteFreely_MultiPlatformApp: App {
} }
private func showLastDraftOrCreateNewLocalPost() { private func showLastDraftOrCreateNewLocalPost() {
#if os(macOS)
if model.editor.lastDraftURL != nil { if model.editor.lastDraftURL != nil {
self.model.selectedPost = model.editor.fetchLastDraftFromAppStorage() DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
self.model.selectedPost = model.editor.fetchLastDraftFromAppStorage()
}
} else { } else {
createNewLocalPost() createNewLocalPost()
} }
#endif
} }
private func createNewLocalPost() { private func createNewLocalPost() {
@ -170,7 +170,7 @@ struct WriteFreely_MultiPlatformApp: App {
let managedPost = model.editor.generateNewLocalPost(withFont: model.preferences.font) let managedPost = model.editor.generateNewLocalPost(withFont: model.preferences.font)
withAnimation { withAnimation {
// Set it as the selectedPost // Set it as the selectedPost
DispatchQueue.main.asyncAfter(deadline: .now()) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
self.model.selectedPost = managedPost self.model.selectedPost = managedPost
} }
} }

View File

@ -1050,7 +1050,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements"; CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 695; CURRENT_PROJECT_VERSION = 699;
DEVELOPMENT_TEAM = TPPAB4YBA6; DEVELOPMENT_TEAM = TPPAB4YBA6;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; INFOPLIST_FILE = "ActionExtension-iOS/Info.plist";
@ -1081,7 +1081,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements"; CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 695; CURRENT_PROJECT_VERSION = 699;
DEVELOPMENT_TEAM = TPPAB4YBA6; DEVELOPMENT_TEAM = TPPAB4YBA6;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; INFOPLIST_FILE = "ActionExtension-iOS/Info.plist";
@ -1224,7 +1224,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements"; CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 695; CURRENT_PROJECT_VERSION = 699;
DEVELOPMENT_TEAM = TPPAB4YBA6; DEVELOPMENT_TEAM = TPPAB4YBA6;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = iOS/Info.plist; INFOPLIST_FILE = iOS/Info.plist;
@ -1250,7 +1250,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements"; CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 695; CURRENT_PROJECT_VERSION = 699;
DEVELOPMENT_TEAM = TPPAB4YBA6; DEVELOPMENT_TEAM = TPPAB4YBA6;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = iOS/Info.plist; INFOPLIST_FILE = iOS/Info.plist;

View File

@ -41,7 +41,7 @@ private struct UITextViewWrapper: UIViewRepresentable {
uiView.font = fontMetrics.scaledFont(for: font) uiView.font = fontMetrics.scaledFont(for: font)
if uiView.window != nil && isEditing { if uiView.window != nil && isEditing {
DispatchQueue.main.async { DispatchQueue.main.asyncAfter(deadline: .now() + 0.55) {
uiView.becomeFirstResponder() uiView.becomeFirstResponder()
} }
} }

View File

@ -60,8 +60,8 @@ struct PostTextEditingView: View {
} }
} }
} }
.onChange(of: titleIsFirstResponder, perform: { _ in .onChange(of: titleIsFirstResponder, perform: { value in
self.bodyIsFirstResponder.toggle() self.bodyIsFirstResponder = !value
}) })
.onAppear(perform: { .onAppear(perform: {
switch post.appearance { switch post.appearance {
@ -75,6 +75,9 @@ struct PostTextEditingView: View {
self.titleTextStyle = UIFont(name: appearance.rawValue, size: 26)! self.titleTextStyle = UIFont(name: appearance.rawValue, size: 26)!
self.bodyTextStyle = UIFont(name: appearance.rawValue, size: 17)! self.bodyTextStyle = UIFont(name: appearance.rawValue, size: 17)!
}) })
.onDisappear {
hideKeyboard()
}
} }
private func didFinishEditingTitle() { private func didFinishEditingTitle() {