// Author: cirakg & claude ai // Summary: The outcome of one import: counts, per-item errors and skips, notes, and the texts for the status field and results screen. import Toybox.Lang; class ImportReport { // At most this many detail lines are kept (the results screen scrolls). static const MAX_DETAILS = 40; var imported as Number = 0; var pendingLocked as Number = 0; var duplicates as Number = 0; var errors as Number = 0; var skipped as Number = 0; var removed as Number = 0; // Set when the whole import failed (not JSON, encrypted, storage full // before anything was stored...). var failure as String? = null; // Set while a multi-part import waits for its next part. var waitingChars as Number = -1; var details as Array = [] as Array; function initialize() { } function addDetail(line as String) as Void { if (details.size() < MAX_DETAILS) { details.add(line); } else if (details.size() == MAX_DETAILS) { details.add("…"); } } // One line for the phone's Import status field, for example // "Imported 12 · 2 duplicates skipped · 1 error · 1 skipped". function summary() as String { var f = failure; if (f != null) { return "Not imported: " + f; } if (waitingChars >= 0) { return "Waiting for more: received " + waitingChars + " characters. Paste the next part into the import fields and turn 'Import now' on again."; } var text = "Imported " + imported; if (pendingLocked > 0) { text += " (" + pendingLocked + " locked, waiting for your PIN)"; } if (removed > 0) { text += " · " + removed + " old imported removed"; } if (duplicates > 0) { text += " · " + duplicates + (duplicates == 1 ? " duplicate skipped" : " duplicates skipped"); } if (errors > 0) { text += " · " + errors + (errors == 1 ? " error" : " errors"); } if (skipped > 0) { text += " · " + skipped + " skipped"; } return text; } // The summary followed by the details, for the results screen. function lines() as Array { var out = [summary()] as Array; out.addAll(details); return out; } }