Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// ActivityKind.swift
// DevLogDomain
// DevLogCore
//
// Created by opfic on 4/4/26.
//
Expand Down
32 changes: 31 additions & 1 deletion Application/DevLogData/Sources/DTO/TodoDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import DevLogDomain

public struct TodoRequest: Encodable {
public let id: String
Expand Down Expand Up @@ -102,3 +101,34 @@ public struct TodoResponse {
self.category = category
}
}

public struct WidgetTodoSnapshot: Equatable {
public let id: String
public let number: Int?
public let title: String
public let isPinned: Bool
public let createdAt: Date
public let completedAt: Date?
public let deletedAt: Date?
public let dueDate: Date?

public init(
id: String,
number: Int?,
title: String,
isPinned: Bool,
createdAt: Date,
completedAt: Date?,
deletedAt: Date?,
dueDate: Date?
) {
self.id = id
self.number = number
self.title = title
self.isPinned = isPinned
self.createdAt = createdAt
self.completedAt = completedAt
self.deletedAt = deletedAt
self.dueDate = dueDate
}
}
15 changes: 15 additions & 0 deletions Application/DevLogData/Sources/Mapper/TodoMapping.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ public extension TodoResponse {
}
}

public extension WidgetTodoSnapshot {
static func fromDomain(_ todo: Todo) -> Self {
Comment thread
opficdev marked this conversation as resolved.
WidgetTodoSnapshot(
id: todo.id,
number: todo.number,
title: todo.title,
isPinned: todo.isPinned,
createdAt: todo.createdAt,
completedAt: todo.completedAt,
deletedAt: todo.deletedAt,
dueDate: todo.dueDate
)
}
}

public extension TodoCursorDTO {
func toDomain() -> TodoCursor {
TodoCursor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation
import DevLogCore
import DevLogDomain

public protocol WidgetSnapshotPreferenceStore {
func heatmapActivityTypes() -> [String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@

import Foundation
import DevLogCore
import DevLogDomain

public protocol WidgetSnapshotUpdater {
func updateTodaySnapshot(
todos: [Todo],
todos: [WidgetTodoSnapshot],
now: Date
)
func updateTodaySnapshot(
todos: [Todo],
todos: [WidgetTodoSnapshot],
displayOptions: TodayDisplayOptions,
now: Date
)
func updateHeatmapSnapshot(
createdTodos: [Todo],
completedTodos: [Todo],
deletedTodos: [Todo],
createdTodos: [WidgetTodoSnapshot],
completedTodos: [WidgetTodoSnapshot],
deletedTodos: [WidgetTodoSnapshot],
quarterStart: Date,
now: Date
)
Expand Down
7 changes: 0 additions & 7 deletions Application/DevLogInfra/DevLogInfra.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
5F7A14F2C5294547884212E1 /* FirebaseCore in Frameworks */ = {isa = PBXBuildFile; productRef = 06ADD17826F44543B09286DA /* FirebaseCore */; };
65623F19F34A9A75BC72EE36 /* FirebaseFirestore in Frameworks */ = {isa = PBXBuildFile; productRef = CE8F32B22E13743B3FF3B66B /* FirebaseFirestore */; };
B11111111111111111111111 /* DevLogCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B55555555555555555555555 /* DevLogCore.framework */; };
E06504AD71E9A40ACCA85ABB /* DevLogDomain.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05A93F27C7172C85CD7252AA /* DevLogDomain.framework */; };
E747320CAD03A579976E87F8 /* FirebaseFunctions in Frameworks */ = {isa = PBXBuildFile; productRef = 172AF9DE3BC54E9E0B4EFD19 /* FirebaseFunctions */; };
EE62AAD289D9CED31CC9E05D /* GoogleSignIn in Frameworks */ = {isa = PBXBuildFile; productRef = 7333E70E9D312E56D4A364A6 /* GoogleSignIn */; };
F085DED20E80F63AE071D8BA /* DevLogData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4F874032FD57C0BBCC41C64 /* DevLogData.framework */; };
Expand Down Expand Up @@ -84,7 +83,6 @@
EE62AAD289D9CED31CC9E05D /* GoogleSignIn in Frameworks */,
FEBF252AD70A910C914D3D22 /* Nexa in Frameworks */,
F085DED20E80F63AE071D8BA /* DevLogData.framework in Frameworks */,
E06504AD71E9A40ACCA85ABB /* DevLogDomain.framework in Frameworks */,
B11111111111111111111111 /* DevLogCore.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -177,7 +175,6 @@
buildRules = (
);
dependencies = (
1F4AAA000000000000000001 /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
959D79D1263CC74E32B40D78 /* Sources */,
Expand Down Expand Up @@ -271,10 +268,6 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
1F4AAA000000000000000001 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 1F4AAA000000000000000003 /* SwiftLintBuildToolPlugin */;
};
1F4AAA000000000000000004 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 1F4AAA000000000000000003 /* SwiftLintBuildToolPlugin */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
4763564ECF9942DCB6A7D3D2 /* DevLogWidgetCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5FF5E1613F059A4B77931161 /* DevLogWidgetCore.framework */; };
4EE7A141A66C408EB8897D4A /* DevLogPersistence.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86E8AA2A43914F444BF5A6C2 /* DevLogPersistence.framework */; };
5F89EB23199E4ABEA925CF92 /* DevLogData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 493A5D0B4274807F2B948AB3 /* DevLogData.framework */; };
7D8DE74BD24B456D42B04806 /* DevLogDomain.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F334BCFC52C730D5901F6051 /* DevLogDomain.framework */; };
8A95AB09613C4F54883A7A38 /* DevLogDomain.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F334BCFC52C730D5901F6051 /* DevLogDomain.framework */; };
A11111111111111111111111 /* DevLogCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A55555555555555555555555 /* DevLogCore.framework */; };
E53E13B73BFAF0C51013ECA2 /* DevLogWidgetCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5FF5E1613F059A4B77931161 /* DevLogWidgetCore.framework */; };
F47DBE7D3E7E49F08D4B5530 /* DevLogCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A55555555555555555555555 /* DevLogCore.framework */; };
Expand All @@ -36,7 +34,6 @@
86E8AA2A43914F444BF5A6C2 /* DevLogPersistence.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DevLogPersistence.framework; sourceTree = BUILT_PRODUCTS_DIR; };
98B16FCDA8A71E2E4E1DC05E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
A55555555555555555555555 /* DevLogCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = DevLogCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F334BCFC52C730D5901F6051 /* DevLogDomain.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = DevLogDomain.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
Expand Down Expand Up @@ -68,7 +65,6 @@
files = (
4EE7A141A66C408EB8897D4A /* DevLogPersistence.framework in Frameworks */,
F47DBE7D3E7E49F08D4B5530 /* DevLogCore.framework in Frameworks */,
8A95AB09613C4F54883A7A38 /* DevLogDomain.framework in Frameworks */,
5F89EB23199E4ABEA925CF92 /* DevLogData.framework in Frameworks */,
4763564ECF9942DCB6A7D3D2 /* DevLogWidgetCore.framework in Frameworks */,
);
Expand All @@ -79,7 +75,6 @@
buildActionMask = 2147483647;
files = (
041CEED3822FCBD881DF75CD /* Foundation.framework in Frameworks */,
7D8DE74BD24B456D42B04806 /* DevLogDomain.framework in Frameworks */,
E53E13B73BFAF0C51013ECA2 /* DevLogWidgetCore.framework in Frameworks */,
3B8FAEC025F373D4CFC262D4 /* DevLogData.framework in Frameworks */,
A11111111111111111111111 /* DevLogCore.framework in Frameworks */,
Expand Down Expand Up @@ -120,7 +115,6 @@
children = (
86E8AA2A43914F444BF5A6C2 /* DevLogPersistence.framework */,
62B066C5B0714BC3B5F4D9D0 /* DevLogPersistenceTests.xctest */,
F334BCFC52C730D5901F6051 /* DevLogDomain.framework */,
5FF5E1613F059A4B77931161 /* DevLogWidgetCore.framework */,
493A5D0B4274807F2B948AB3 /* DevLogData.framework */,
A55555555555555555555555 /* DevLogCore.framework */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation
import DevLogCore
import DevLogData
import DevLogDomain

final class WidgetSnapshotPreferenceStoreImpl: WidgetSnapshotPreferenceStore {
private enum Key: String, CaseIterable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation
import WidgetKit
import DevLogCore
import DevLogDomain
import DevLogData
import DevLogWidgetCore

Expand All @@ -32,7 +31,7 @@ final class WidgetSnapshotUpdaterImpl: WidgetSnapshotUpdater {
}

func updateTodaySnapshot(
todos: [Todo],
todos: [WidgetTodoSnapshot],
now: Date = Date()
) {
updateTodaySnapshot(
Expand All @@ -43,7 +42,7 @@ final class WidgetSnapshotUpdaterImpl: WidgetSnapshotUpdater {
}

func updateTodaySnapshot(
todos: [Todo],
todos: [WidgetTodoSnapshot],
displayOptions: TodayDisplayOptions,
now: Date = Date()
) {
Expand All @@ -65,9 +64,9 @@ final class WidgetSnapshotUpdaterImpl: WidgetSnapshotUpdater {
}

func updateHeatmapSnapshot(
createdTodos: [Todo],
completedTodos: [Todo],
deletedTodos: [Todo],
createdTodos: [WidgetTodoSnapshot],
completedTodos: [WidgetTodoSnapshot],
deletedTodos: [WidgetTodoSnapshot],
quarterStart: Date,
now: Date = Date()
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import Foundation
import DevLogDomain
import DevLogCore
import Testing
@testable import DevLogPersistence

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation
import DevLogCore
import DevLogDomain
import DevLogData
import Testing
@testable import DevLogPersistence
@testable import DevLogWidgetCore
Expand Down Expand Up @@ -150,22 +150,16 @@ struct WidgetSnapshotUpdaterTests {
completedAt: Date? = nil,
deletedAt: Date? = nil,
dueDate: Date? = nil
) -> Todo {
Todo(
) -> WidgetTodoSnapshot {
WidgetTodoSnapshot(
id: id,
isPinned: false,
isCompleted: completedAt != nil,
isChecked: false,
number: 1,
title: id,
content: "",
isPinned: false,
createdAt: createdAt,
updatedAt: createdAt,
completedAt: completedAt,
deletedAt: deletedAt,
dueDate: dueDate,
tags: [],
category: .system(.feature)
dueDate: dueDate
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import SwiftUI
import DevLogDomain
import DevLogCore

struct HeatmapView: View {
@State private var availableWidth = CGFloat.zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import SwiftUI
import DevLogDomain
import DevLogCore

public struct ActivityKindItem: Identifiable, Hashable {
private let activityKind: ActivityKind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
import DevLogCore
import DevLogDomain

public struct HeatmapActivityItem: Identifiable, Hashable, Comparable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import Foundation
import DevLogDomain
import DevLogCore
import DevLogData

public struct HeatmapWidgetSnapshotFactory {
Expand Down Expand Up @@ -34,9 +34,9 @@ public struct HeatmapWidgetSnapshotFactory {
}

public func makeSnapshot(
createdTodos: [Todo],
completedTodos: [Todo],
deletedTodos: [Todo],
createdTodos: [WidgetTodoSnapshot],
completedTodos: [WidgetTodoSnapshot],
deletedTodos: [WidgetTodoSnapshot],
selectedActivityKinds: Set<ActivityKind>,
quarterStart: Date,
now: Date = Date()
Expand Down Expand Up @@ -78,9 +78,9 @@ public struct HeatmapWidgetSnapshotFactory {

private extension HeatmapWidgetSnapshotFactory {
func makeDailyCountsByDate(
createdTodos: [Todo],
completedTodos: [Todo],
deletedTodos: [Todo],
createdTodos: [WidgetTodoSnapshot],
completedTodos: [WidgetTodoSnapshot],
deletedTodos: [WidgetTodoSnapshot],
quarterStart: Date,
nextQuarterStart: Date
) -> [Date: DailyCounts] {
Expand Down
24 changes: 12 additions & 12 deletions Widget/DevLogWidgetCore/Sources/Sync/WidgetSyncEventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ private extension WidgetSyncEventHandler {
case .syncRequested:
Task { [weak self] in
guard let self else { return }
async let todaySnapshot: Void = updateTodayWidgetSnapshot()
async let heatmapSnapshot: Void = updateHeatmapWidgetSnapshot()
let now = Date()
async let todaySnapshot: Void = updateTodayWidgetSnapshot(now: now)
async let heatmapSnapshot: Void = updateHeatmapWidgetSnapshot(now: now)
_ = await (todaySnapshot, heatmapSnapshot)
}
}
}

func updateTodayWidgetSnapshot() async {
func updateTodayWidgetSnapshot(now: Date) async {
do {
async let todosWithDueDate = fetchTodayTodos(
dueDateFilter: .withDueDate,
Expand All @@ -64,8 +65,8 @@ private extension WidgetSyncEventHandler {
todosWithoutDueDate
)
snapshotUpdater.updateTodaySnapshot(
todos: todayTodosWithDueDate + todayTodosWithoutDueDate,
now: Date()
todos: (todayTodosWithDueDate + todayTodosWithoutDueDate).map(WidgetTodoSnapshot.fromDomain),
now: now
)
} catch {
logger.error(
Expand All @@ -75,9 +76,8 @@ private extension WidgetSyncEventHandler {
}
}

func updateHeatmapWidgetSnapshot() async {
let currentDate = Date()
let quarterStart = Calendar.current.startOfQuarter(for: currentDate)
func updateHeatmapWidgetSnapshot(now: Date) async {
let quarterStart = Calendar.current.startOfQuarter(for: now)
guard let nextQuarterStart = Calendar.current.date(byAdding: .month, value: 3, to: quarterStart) else {
return
}
Expand All @@ -104,11 +104,11 @@ private extension WidgetSyncEventHandler {
deletedTodos
)
snapshotUpdater.updateHeatmapSnapshot(
createdTodos: createdTodoItems,
completedTodos: completedTodoItems,
deletedTodos: deletedTodoItems,
createdTodos: createdTodoItems.map(WidgetTodoSnapshot.fromDomain),
completedTodos: completedTodoItems.map(WidgetTodoSnapshot.fromDomain),
deletedTodos: deletedTodoItems.map(WidgetTodoSnapshot.fromDomain),
quarterStart: quarterStart,
now: currentDate
now: now
)
} catch {
logger.error(
Expand Down
Loading