From d8125ddf34cf72dde9ea99a006b9d30d07c2dc7e Mon Sep 17 00:00:00 2001 From: wangdl Date: Thu, 18 Jun 2026 16:58:23 +0800 Subject: [PATCH] fix: iOS compile errors - protocol mismatches + void return MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ReadingRuntimeAdapter: clearExportedEvents is void, return count separately - ActivityViewModel: FocusItemServicing.list→listAll, add days/type? params - ActivityViewModelTests: update mocks to match new protocol signatures Co-Authored-By: Claude Opus 4.7 --- .../Core/Services/ReadingRuntimeAdapter.swift | 6 +++-- .../Features/Analysis/ActivityViewModel.swift | 22 ++++++++++--------- .../ActivityViewModelTests.swift | 6 ++--- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/AIStudyApp/AIStudyApp/Core/Services/ReadingRuntimeAdapter.swift b/AIStudyApp/AIStudyApp/Core/Services/ReadingRuntimeAdapter.swift index 14333fb..270b465 100644 --- a/AIStudyApp/AIStudyApp/Core/Services/ReadingRuntimeAdapter.swift +++ b/AIStudyApp/AIStudyApp/Core/Services/ReadingRuntimeAdapter.swift @@ -154,12 +154,14 @@ final class V1ReadingRuntimeAdapter: ReadingRuntimeAdapter { } func ackEvents(_ eventIds: [String]) -> UInt32 { - return clearExportedEvents(count: UInt32(eventIds.count)) + clearExportedEvents(count: UInt32(eventIds.count)) + return UInt32(eventIds.count) } func markFailed(_ eventIds: [String]) -> UInt32 { // V1 has no mark-failed mechanism — clear them to avoid blocking - return clearExportedEvents(count: UInt32(eventIds.count)) + clearExportedEvents(count: UInt32(eventIds.count)) + return UInt32(eventIds.count) } func reloadStaleEvents() -> UInt32 { return 0 } diff --git a/AIStudyApp/AIStudyApp/Features/Analysis/ActivityViewModel.swift b/AIStudyApp/AIStudyApp/Features/Analysis/ActivityViewModel.swift index 1892a93..084552d 100644 --- a/AIStudyApp/AIStudyApp/Features/Analysis/ActivityViewModel.swift +++ b/AIStudyApp/AIStudyApp/Features/Analysis/ActivityViewModel.swift @@ -13,9 +13,11 @@ protocol ActivityServicing { extension ActivityService: ActivityServicing {} protocol FocusItemServicing { - func list() async throws -> [FocusItem] + func listAll() async throws -> [FocusItem] +} +extension FocusItemService: FocusItemServicing { + func listAll() async throws -> [FocusItem] { try await list() } } -extension FocusItemService: FocusItemServicing {} protocol ReadingContinueServicing { func getContinueLearning() async throws -> ContinueLearningResponse @@ -24,8 +26,8 @@ extension ReadingAPIService: ReadingContinueServicing {} protocol LearningStatusServicing { func getLearningSummary() async throws -> LearningSummaryResponse - func getLearningTrend() async throws -> LearningTrendResponse - func getLearningRecords(limit: Int, type: String) async throws -> LearningRecordsResponse + func getLearningTrend(days: Int) async throws -> LearningTrendResponse + func getLearningRecords(limit: Int, type: String?) async throws -> LearningRecordsResponse } extension ReadingAPIService: LearningStatusServicing {} @@ -65,14 +67,14 @@ class ActivityViewModel: ObservableObject { errorMessage = nil async let s = try? activityService.summary() - async let f = try? focusService.list() + async let f = try? focusService.listAll() async let h = try? activityService.heatmap() async let st = try? activityService.streak() - async let t = try? activityService.trend() + async let t = try? activityService.trend(days: 7) async let r = try? activityService.recommendations() async let cr = try? readingService.getContinueLearning() async let ls = try? readingService.getLearningSummary() - async let ltr = try? readingService.getLearningTrend() + async let ltr = try? readingService.getLearningTrend(days: 7) async let recs = try? readingService.getLearningRecords(limit: 10, type: "reading") let (summaryResult, focusResult, heatmapResult, streakResult, trendResult, recResult, continueResult, lsResult, ltrResult, recordsResult) = await (s, f, h, st, t, r, cr, ls, ltr, recs) @@ -99,14 +101,14 @@ class ActivityViewModel: ObservableObject { errorMessage = nil async let s = try? activityService.summary() - async let f = try? focusService.list() + async let f = try? focusService.listAll() async let h = try? activityService.heatmap() async let st = try? activityService.streak() - async let t = try? activityService.trend() + async let t = try? activityService.trend(days: 7) async let r = try? activityService.recommendations() async let cr = try? readingService.getContinueLearning() async let ls = try? readingService.getLearningSummary() - async let ltr = try? readingService.getLearningTrend() + async let ltr = try? readingService.getLearningTrend(days: 7) async let recs = try? readingService.getLearningRecords(limit: 10, type: "reading") let (summaryResult, focusResult, heatmapResult, streakResult, trendResult, recResult, continueResult, lsResult, ltrResult, recordsResult) = await (s, f, h, st, t, r, cr, ls, ltr, recs) diff --git a/AIStudyApp/AIStudyAppTests/ActivityViewModelTests.swift b/AIStudyApp/AIStudyAppTests/ActivityViewModelTests.swift index 997c600..a3522d4 100644 --- a/AIStudyApp/AIStudyAppTests/ActivityViewModelTests.swift +++ b/AIStudyApp/AIStudyAppTests/ActivityViewModelTests.swift @@ -19,7 +19,7 @@ private final class MockActivityService: ActivityServicing { private final class MockFocusItemService: FocusItemServicing { var items: [FocusItem] = [] - func list() async throws -> [FocusItem] { items } + func listAll() async throws -> [FocusItem] { items } } private final class MockReadingAPIForActivity: ReadingContinueServicing & LearningStatusServicing { @@ -30,8 +30,8 @@ private final class MockReadingAPIForActivity: ReadingContinueServicing & Learni func getContinueLearning() async throws -> ContinueLearningResponse { try resultOrThrow(continueLearning) } func getLearningSummary() async throws -> LearningSummaryResponse { try resultOrThrow(learningSummary) } - func getLearningTrend() async throws -> LearningTrendResponse { try resultOrThrow(learningTrend) } - func getLearningRecords(limit: Int, type: String) async throws -> LearningRecordsResponse { try resultOrThrow(records) } + func getLearningTrend(days: Int) async throws -> LearningTrendResponse { try resultOrThrow(learningTrend) } + func getLearningRecords(limit: Int, type: String?) async throws -> LearningRecordsResponse { try resultOrThrow(records) } } private func resultOrThrow(_ value: T?) throws -> T {