add version text
This commit is contained in:
@@ -108,7 +108,7 @@ class PackageModel extends BaseModel {
|
||||
if (forCustomer) {
|
||||
q = q.where("user_id", isEqualTo: user.id);
|
||||
}
|
||||
q = q.orderBy("tracking_id", descending: false);
|
||||
q = q.orderBy("update_time", descending: true);
|
||||
listener = q.snapshots().listen((QuerySnapshot snapshot) {
|
||||
_packages.clear();
|
||||
_packages = snapshot.documents.map((documentSnapshot) {
|
||||
@@ -139,6 +139,25 @@ class PackageModel extends BaseModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<Package> getPackageByTrackingID(String trackingID) async {
|
||||
if (user == null) return null;
|
||||
String path = "/$packages_collection";
|
||||
try {
|
||||
var snaps = await Firestore.instance
|
||||
.collection("$path")
|
||||
.where("tracking_id", isEqualTo: trackingID)
|
||||
.getDocuments(source: Source.server);
|
||||
if (snaps.documents.length == 1) {
|
||||
var snap = snaps.documents[0];
|
||||
var package = Package.fromMap(snap.data, snap.documentID);
|
||||
return package;
|
||||
}
|
||||
} catch (e) {
|
||||
log.warning("Error!! $e");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<Package> lookupPackage(String trackingID) async {
|
||||
if (user == null) return null;
|
||||
String path = "/$packages_collection";
|
||||
@@ -201,8 +220,15 @@ class PackageModel extends BaseModel {
|
||||
return Services.instance.userService.searchUser(term);
|
||||
}
|
||||
|
||||
Future<List<Package>> searchPackage(String term) {
|
||||
return Services.instance.packageService.searchPackage(term);
|
||||
Future<List<Package>> searchPackage(String term) async {
|
||||
List<Package> packages =
|
||||
await Services.instance.packageService.searchPackage(term);
|
||||
|
||||
Package pkg = await getPackageByTrackingID(term);
|
||||
if (pkg != null && !packages.contains(pkg)) {
|
||||
packages.insert(0, pkg);
|
||||
}
|
||||
return packages;
|
||||
}
|
||||
|
||||
Future<void> createPackages(User user, List<Package> packages) {
|
||||
@@ -216,7 +242,8 @@ class PackageModel extends BaseModel {
|
||||
package.fcsID = user.fcsID;
|
||||
}
|
||||
if (files != null) {
|
||||
if (files.length > 5) throw Exception("Exceed number of file upload");
|
||||
if (files.length > uploadPhotoLimit)
|
||||
throw Exception("Exceed number of file upload");
|
||||
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
|
||||
for (File f in files) {
|
||||
String path = Path.join(pkg_files_path);
|
||||
@@ -240,7 +267,12 @@ class PackageModel extends BaseModel {
|
||||
}
|
||||
|
||||
if (files != null) {
|
||||
if (files.length > 5) throw Exception("Exceed number of file upload");
|
||||
var count = (package.photoUrls?.length ?? 0) +
|
||||
files.length -
|
||||
(deletedUrls?.length ?? 0);
|
||||
|
||||
if (count > uploadPhotoLimit)
|
||||
throw Exception("Exceed number of file upload");
|
||||
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
|
||||
for (File f in files) {
|
||||
String path = Path.join(pkg_files_path);
|
||||
@@ -265,7 +297,12 @@ class PackageModel extends BaseModel {
|
||||
}
|
||||
|
||||
if (files != null) {
|
||||
if (files.length > 5) throw Exception("Exceed number of file upload");
|
||||
var count = (package.photoUrls?.length ?? 0) +
|
||||
files.length -
|
||||
(deletedUrls?.length ?? 0);
|
||||
|
||||
if (count > uploadPhotoLimit)
|
||||
throw Exception("Exceed number of file upload");
|
||||
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
|
||||
for (File f in files) {
|
||||
String path = Path.join(pkg_files_path);
|
||||
|
||||
Reference in New Issue
Block a user