Skip to content

Commit

Permalink
Add extra logging for annotation user (#1029)
Browse files Browse the repository at this point in the history
* Add extra logging for annotation user

* Log explicit user id when user is not found when creating annotation
  • Loading branch information
mvasilak authored Nov 26, 2024
1 parent f75bf36 commit ba48669
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import UIKit

import CocoaLumberjackSwift
import RealmSwift

struct CreatePDFAnnotationsDbRequest: DbRequest {
Expand Down Expand Up @@ -62,7 +63,11 @@ struct CreatePDFAnnotationsDbRequest: DbRequest {
item.parent = parent

if annotation.isAuthor {
item.createdBy = database.object(ofType: RUser.self, forPrimaryKey: self.userId)
let user = database.object(ofType: RUser.self, forPrimaryKey: userId)
item.createdBy = user
if user == nil {
DDLogWarn("CreatePDFAnnotationsDbRequest: user not found for userId \(userId)")
}
}

// We need to submit tags on creation even if they are empty, so we need to mark them as changed
Expand Down
9 changes: 8 additions & 1 deletion Zotero/Scenes/Detail/PDF/PDFCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ final class PDFCoordinator: Coordinator {
else { return }

let settings = Defaults.shared.pdfSettings
let displayName = Defaults.shared.displayName
if userId == 0 {
DDLogWarn("PDFCoordinator: userId is not initialized")
}
if displayName.isEmpty {
DDLogWarn("PDFCoordinator: displayName is empty")
}
let handler = PDFReaderActionHandler(
dbStorage: dbStorage,
annotationPreviewController: self.controllers.annotationPreviewController,
Expand All @@ -142,7 +149,7 @@ final class PDFCoordinator: Coordinator {
settings: settings,
userId: userId,
username: username,
displayName: Defaults.shared.displayName,
displayName: displayName,
interfaceStyle: settings.appearanceMode == .automatic ? parentNavigationController.view.traitCollection.userInterfaceStyle : settings.appearanceMode.userInterfaceStyle
)
let controller = PDFReaderViewController(
Expand Down

0 comments on commit ba48669

Please sign in to comment.