Skip to content

Commit

Permalink
Added comment text in activity log
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-nirali-s committed Jan 9, 2025
1 parent 0059f08 commit 776557d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Data/Data/Model/ActivityLog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ public struct ActivityLog: Codable, Identifiable, Hashable {
public let previousGroupName: String?
public let removedMemberName: String?
public let expenseName: String?
public let comment: String?
public let payerName: String?
public let receiverName: String?
public let paymentReason: String?
public let amount: Double?

public init(type: ActivityType, groupId: String, activityId: String, groupName: String,
actionUserName: String, recordedOn: Timestamp, previousGroupName: String? = nil,
removedMemberName: String? = nil, expenseName: String? = nil, payerName: String? = nil,
receiverName: String? = nil, paymentReason: String? = nil, amount: Double? = nil) {
removedMemberName: String? = nil, expenseName: String? = nil, comment: String? = nil,
payerName: String? = nil, receiverName: String? = nil, paymentReason: String? = nil,
amount: Double? = nil) {
self.type = type
self.groupId = groupId
self.activityId = activityId
Expand All @@ -43,6 +45,7 @@ public struct ActivityLog: Codable, Identifiable, Hashable {
self.previousGroupName = previousGroupName
self.removedMemberName = removedMemberName
self.expenseName = expenseName
self.comment = comment
self.payerName = payerName
self.receiverName = receiverName
self.paymentReason = paymentReason
Expand All @@ -60,6 +63,7 @@ public struct ActivityLog: Codable, Identifiable, Hashable {
case previousGroupName = "previous_group_name"
case removedMemberName = "removed_member_name"
case expenseName = "expense_name"
case comment
case payerName = "payer_name"
case receiverName = "receiver_name"
case paymentReason = "payment_reason"
Expand Down
2 changes: 1 addition & 1 deletion Data/Data/Repository/ExpenseRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public class ExpenseRepository: ObservableObject {

return ActivityLog(type: context.type, groupId: groupId, activityId: expenseId, groupName: group.name,
actionUserName: actionUserName, recordedOn: Timestamp(date: Date()),
expenseName: expense.name, amount: amount)
expenseName: expense.name, comment: expense.comments?.last?.comment, amount: amount)
}

private func addActivityLog(context: ActivityLogContext) async -> Error? {
Expand Down
3 changes: 2 additions & 1 deletion Splito/UI/Home/ActivityLog/ActivityLogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ private struct ActivityLogDescriptionView: View {

@ViewBuilder
private func expenseCommentAddedDescription() -> some View {
let comment = activityLog.comment ?? "Some comment"
highlightedText(actionUserName) + disabledText(" commented on") + highlightedText(" \"\(activityLog.expenseName ?? "")\"") +
disabledText(" in") + highlightedText(" \"\(groupName)\".")
disabledText(" in") + highlightedText(" \"\(groupName)\":") + disabledText(" \"\(comment)\".")
}

@ViewBuilder
Expand Down

0 comments on commit 776557d

Please sign in to comment.