Skip to content

Commit 888ba8e

Browse files
committed
Add TTFD to favorites screen
1 parent d3737eb commit 888ba8e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Modules/Sources/FavoritesFeature/FavoritesFeature.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Models
1313
import TCAExtensions
1414
import PasteboardClient
1515
import NotificationCenterClient
16+
import AnalyticsClient
1617

1718
@Reducer
1819
public struct FavoritesFeature: Reducer, Sendable {
@@ -43,6 +44,8 @@ public struct FavoritesFeature: Reducer, Sendable {
4344
return userSession != nil
4445
}
4546

47+
var didLoadOnce = false
48+
4649
public init(
4750
favorites: [FavoriteInfo] = [],
4851
favoritesImportant: [FavoriteInfo] = []
@@ -79,6 +82,7 @@ public struct FavoritesFeature: Reducer, Sendable {
7982
// MARK: - Dependencies
8083

8184
@Dependency(\.apiClient) private var apiClient
85+
@Dependency(\.analyticsClient) private var analyticsClient
8286
@Dependency(\.pasteboardClient) private var pasteboardClient
8387
@Dependency(\.notificationCenter) private var notificationCenter
8488
@Dependency(\.continuousClock) var clock
@@ -248,7 +252,7 @@ public struct FavoritesFeature: Reducer, Sendable {
248252
favorites.append(favorite)
249253
}
250254
}
251-
255+
252256
state.favoritesImportant = favsImportant
253257
state.favorites = favorites
254258

@@ -258,10 +262,13 @@ public struct FavoritesFeature: Reducer, Sendable {
258262
state.isLoading = false
259263
state.isRefreshing = false
260264

265+
reportFullyDisplayed(&state)
266+
261267
return .none
262268

263269
case let ._favoritesResponse(.failure(error)):
264270
print("FAVORITES RESPONSE FAILURE: \(error)")
271+
reportFullyDisplayed(&state)
265272
return .none
266273

267274
case let ._startUnreadLoadingIndicator(id: id):
@@ -279,6 +286,12 @@ public struct FavoritesFeature: Reducer, Sendable {
279286
}
280287
}
281288

289+
private func reportFullyDisplayed(_ state: inout State) {
290+
guard !state.didLoadOnce else { return }
291+
analyticsClient.reportFullyDisplayed()
292+
state.didLoadOnce = true
293+
}
294+
282295
private func goToEnd(id: Int) -> Effect<Action> {
283296
return .merge(
284297
.run { send in

0 commit comments

Comments
 (0)