Skip to content

Conversation

Copy link

Copilot AI commented Nov 10, 2025

Addresses feedback from #202: FoodItem was created at line 86 but never used for persistence, as line 119 switched to using foodItemData map instead.

Changes:

  • Remove premature FoodItem instantiation before Firestore operation
  • Create FoodItem only after successful persistence when needed for logging and callbacks
  • Eliminate .copy() operations by constructing FoodItem with final values directly

Before:

val foodItem = FoodItem(barcode = cleanedBarcode, ...) // Created but unused for persistence
val foodItemData = mutableMapOf(...) // Actually persisted to Firestore

firestore.collection("foodItems").add(foodItemData)
  .addOnSuccessListener {
    logActivity(foodItem.copy(id = documentReference.id), ...)
    onSuccess(foodItem.copy(id = documentReference.id, daysDifference = daysDifference))
  }

After:

val foodItemData = mutableMapOf(...) // Persisted to Firestore

firestore.collection("foodItems").add(foodItemData)
  .addOnSuccessListener {
    val foodItem = FoodItem(id = documentReference.id, barcode = cleanedBarcode, ...)
    logActivity(foodItem, ...)
    onSuccess(foodItem)
  }

Clarifies that foodItemData map is the persistence structure, FoodItem is used only for domain logic after persistence succeeds.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: maxschwinghammer <111356450+maxschwinghammer@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 10, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/agents/gradle-instrumentation-agent-8.13.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.13 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] WIP Address feedback on storing barcode functionality Remove unnecessary FoodItem instantiation in addProduct Nov 10, 2025
Copilot finished work on behalf of maxschwinghammer November 10, 2025 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants