fix profile

This commit is contained in:
Sai Naw Wun
2020-10-11 02:17:23 +06:30
parent b0ce53f856
commit 32e6be2abd
42 changed files with 938 additions and 626 deletions

View File

@@ -93,6 +93,24 @@ class PackageModel extends BaseModel {
.createPackages(packages, user.fcsID);
}
Future<void> createPackage(User user, Package package, List<File> files,
List<String> deletedUrls) async {
if (user != null) {
package.fcsID = user.fcsID;
}
if (files != null) {
if (files.length > 5) 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);
String url = await uploadStorage(path, f);
package.photoUrls.add(url);
}
package.photoUrls.removeWhere((e) => deletedUrls.contains(e));
}
return Services.instance.packageService.createPackage(package);
}
Future<void> completeProcessing(
Package package, List<File> files, List<String> deletedUrls) async {
if (files != null) {
@@ -105,7 +123,7 @@ class PackageModel extends BaseModel {
}
package.photoUrls.removeWhere((e) => deletedUrls.contains(e));
}
await request("/packages", "PUT",
await request("/package", "PUT",
payload: package.toJson(), token: await getToken());
}