Skip to content

Commit cffc8a2

Browse files
graycreateclaude
andcommitted
fix: address Copilot review comments for splash screen
- Use runInMain utility instead of DispatchQueue.main.asyncAfter - Use LaunchFinishedAction and Redux pattern instead of direct state mutation - Change TypewriterView Task type from Task<Void, Error>? to Task<Void, Never>? since the task doesn't throw errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 6efdd2d commit cffc8a2

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

V2er/State/DataFlow/Actions/GlobalActions.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ struct ShowToastAction: Action {
4040
var icon: String = .empty
4141
}
4242

43+
struct LaunchFinishedAction: Action {
44+
var target: Reducer = R
45+
}
46+
4347

4448
func globalStateReducer(_ state: GlobalState, _ action: Action?) -> (GlobalState, Action?) {
4549
var state = state
@@ -50,6 +54,9 @@ func globalStateReducer(_ state: GlobalState, _ action: Action?) -> (GlobalState
5054
state.toast.icon = action.icon
5155
state.toast.isPresented = true
5256
break
57+
case _ as LaunchFinishedAction:
58+
state.launchFinished = true
59+
break
5360
default:
5461
break
5562
}

V2er/View/Splash/SplashView.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,13 @@ struct SplashView: View {
4444
}
4545
.onAppear {
4646
// Show slogan after a short delay
47-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
47+
runInMain(delay: 300) {
4848
showSlogan = true
4949
}
5050

5151
// Hide splash after animation completes
52-
DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
53-
withAnimation(.easeOut(duration: 0.3)) {
54-
store.appState.globalState.launchFinished = true
55-
}
52+
runInMain(delay: 1200) {
53+
store.dispatch(LaunchFinishedAction(), animation: .easeOut(duration: 0.3))
5654
}
5755
}
5856
}

V2er/View/Splash/TypewriterView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct TypewriterView: View {
1313
var easeIn: Bool = true
1414

1515
@State private var animatedText: AttributedString = ""
16-
@State private var typingTask: Task<Void, Error>?
16+
@State private var typingTask: Task<Void, Never>?
1717
@State private var hasAppeared = false
1818

1919
var body: some View {
@@ -43,7 +43,7 @@ struct TypewriterView: View {
4343
var index = animatedText.startIndex
4444

4545
while index < animatedText.endIndex {
46-
try Task.checkCancellation()
46+
guard !Task.isCancelled else { return }
4747

4848
// Update the style
4949
animatedText[animatedText.startIndex...index]
@@ -65,7 +65,7 @@ struct TypewriterView: View {
6565
}
6666

6767
// Wait
68-
try await Task.sleep(for: delay)
68+
try? await Task.sleep(for: delay)
6969

7070
// Advance the index, character by character
7171
index = animatedText.index(afterCharacter: index)

0 commit comments

Comments
 (0)