feat(app): scan-mode sync, confirmation-gated documents, single-pass product classification
Fixes reported from APK field testing: DO/Product scan mode was inconsistent between the camera drawer and documents screen (now one shared provider, with an orange/green color cue); unconfirmed scans leaked into history with placeholder data before the user tapped confirm (backend now gates GET /documents on a new `confirmed` column, flipped only by PUT); and Product Scan ran the GPU classifier twice, once at upload and again on review (now a single pass at upload, persisted and read directly by the editor). Also removes the unused "Hubungkan ke PO" field and fabricated PO/SO/DO placeholder values from the Product Scan flow, closes out the per-document-polling and save-recovery tasks (6.1/6.3), and splits several touched files to stay under the repo's 256-line guideline. Full detail in docs/iteration-log.md and backend/docs/iteration-log.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2febe0c886
commit
ada6488592
67 files changed
+5705
-1142
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import '../../models/document_model.dart';
|
||||
|
||||
/// Result of merging the server's document list with local corrections that
|
||||
/// haven't made it back to the server yet.
|
||||
class MergedDocuments {
|
||||
final List<DocumentModel> docs;
|
||||
final Set<String> unsyncedIds;
|
||||
|
||||
const MergedDocuments(this.docs, this.unsyncedIds);
|
||||
}
|
||||
|
||||
/// Merges the server's authoritative document list with local corrections for
|
||||
/// documents whose `PUT` sync failed (`syncFailed` in the pending queue).
|
||||
///
|
||||
/// Without this, refreshing the documents list would silently overwrite a
|
||||
/// driver's corrected-but-unsynced edit with the server's stale pre-edit copy
|
||||
/// on every successful fetch - the correction is still recoverable via the
|
||||
/// pending queue's retry action, but the history list would show the wrong
|
||||
/// data (or the document would vanish from it entirely) until the retry
|
||||
/// succeeds. `unsyncedOverrides` wins over `serverDocs` for matching ids, and
|
||||
/// is kept even if the server list doesn't (yet) include that id at all.
|
||||
MergedDocuments mergeDocumentsWithUnsyncedOverrides({
|
||||
required List<DocumentModel> serverDocs,
|
||||
required Map<String, DocumentModel> unsyncedOverrides,
|
||||
}) {
|
||||
final merged = <String, DocumentModel>{
|
||||
for (final doc in serverDocs) doc.id: doc,
|
||||
};
|
||||
for (final entry in unsyncedOverrides.entries) {
|
||||
merged[entry.key] = entry.value;
|
||||
}
|
||||
return MergedDocuments(merged.values.toList(), unsyncedOverrides.keys.toSet());
|
||||
}
|
||||
Reference in new issue
Block a user