Skip to content

Commit 040f398

Browse files
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
1 parent 5261809 commit 040f398

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4646
- [Mac] Fixed some build warnings in the project.
4747
- [Mac] Bumped WriteFreely package to v0.3.6 to handle decoding of fractional seconds in dates.
4848
- [iOS] Fixed a bug where posts were always shown in serif, even if the post was published with another font.
49+
- [iOS] Restored the new-draft-on-launch feature and resolves crashing bug.
50+
- [iOS] Fixed a bug that would navigate to a post on launch, then immediately navigate back to the post list.
51+
- [iOS] Fixed some animation glitches when presenting and dismissing the keyboard.
4952

5053
## [1.0.14-ios] - 2022-12-18
5154

Shared/WriteFreely_MultiPlatformApp.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ struct WriteFreely_MultiPlatformApp: App {
152152
}
153153

154154
private func showLastDraftOrCreateNewLocalPost() {
155-
#if os(macOS)
156155
if model.editor.lastDraftURL != nil {
157-
self.model.selectedPost = model.editor.fetchLastDraftFromAppStorage()
156+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
157+
self.model.selectedPost = model.editor.fetchLastDraftFromAppStorage()
158+
}
158159
} else {
159160
createNewLocalPost()
160161
}
161-
#endif
162162
}
163163

164164
private func createNewLocalPost() {
@@ -170,7 +170,7 @@ struct WriteFreely_MultiPlatformApp: App {
170170
let managedPost = model.editor.generateNewLocalPost(withFont: model.preferences.font)
171171
withAnimation {
172172
// Set it as the selectedPost
173-
DispatchQueue.main.asyncAfter(deadline: .now()) {
173+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
174174
self.model.selectedPost = managedPost
175175
}
176176
}

WriteFreely-MultiPlatform.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@
10501050
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
10511051
CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements";
10521052
CODE_SIGN_STYLE = Automatic;
1053-
CURRENT_PROJECT_VERSION = 695;
1053+
CURRENT_PROJECT_VERSION = 699;
10541054
DEVELOPMENT_TEAM = TPPAB4YBA6;
10551055
GENERATE_INFOPLIST_FILE = YES;
10561056
INFOPLIST_FILE = "ActionExtension-iOS/Info.plist";
@@ -1081,7 +1081,7 @@
10811081
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
10821082
CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements";
10831083
CODE_SIGN_STYLE = Automatic;
1084-
CURRENT_PROJECT_VERSION = 695;
1084+
CURRENT_PROJECT_VERSION = 699;
10851085
DEVELOPMENT_TEAM = TPPAB4YBA6;
10861086
GENERATE_INFOPLIST_FILE = YES;
10871087
INFOPLIST_FILE = "ActionExtension-iOS/Info.plist";
@@ -1224,7 +1224,7 @@
12241224
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
12251225
CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements";
12261226
CODE_SIGN_STYLE = Automatic;
1227-
CURRENT_PROJECT_VERSION = 695;
1227+
CURRENT_PROJECT_VERSION = 699;
12281228
DEVELOPMENT_TEAM = TPPAB4YBA6;
12291229
ENABLE_PREVIEWS = YES;
12301230
INFOPLIST_FILE = iOS/Info.plist;
@@ -1250,7 +1250,7 @@
12501250
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
12511251
CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements";
12521252
CODE_SIGN_STYLE = Automatic;
1253-
CURRENT_PROJECT_VERSION = 695;
1253+
CURRENT_PROJECT_VERSION = 699;
12541254
DEVELOPMENT_TEAM = TPPAB4YBA6;
12551255
ENABLE_PREVIEWS = YES;
12561256
INFOPLIST_FILE = iOS/Info.plist;

iOS/PostEditor/MultilineTextView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private struct UITextViewWrapper: UIViewRepresentable {
4141
uiView.font = fontMetrics.scaledFont(for: font)
4242

4343
if uiView.window != nil && isEditing {
44-
DispatchQueue.main.async {
44+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.55) {
4545
uiView.becomeFirstResponder()
4646
}
4747
}

iOS/PostEditor/PostTextEditingView.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ struct PostTextEditingView: View {
6060
}
6161
}
6262
}
63-
.onChange(of: titleIsFirstResponder, perform: { _ in
64-
self.bodyIsFirstResponder.toggle()
63+
.onChange(of: titleIsFirstResponder, perform: { value in
64+
self.bodyIsFirstResponder = !value
6565
})
6666
.onAppear(perform: {
6767
switch post.appearance {
@@ -75,6 +75,9 @@ struct PostTextEditingView: View {
7575
self.titleTextStyle = UIFont(name: appearance.rawValue, size: 26)!
7676
self.bodyTextStyle = UIFont(name: appearance.rawValue, size: 17)!
7777
})
78+
.onDisappear {
79+
hideKeyboard()
80+
}
7881
}
7982

8083
private func didFinishEditingTitle() {

0 commit comments

Comments
 (0)