cleanup code
This commit is contained in:
@@ -258,7 +258,7 @@ class PackageModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<void> createReceiving(
|
||||
User user, Package package, List<File?> files) async {
|
||||
User? user, Package package, List<File?>? files) async {
|
||||
if (user != null) {
|
||||
package.fcsID = user.fcsID;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ class PackageModel extends BaseModel {
|
||||
throw Exception("Exceed number of file upload");
|
||||
}
|
||||
|
||||
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
|
||||
package.photoUrls = package.photoUrls;
|
||||
String path = Path.join(pkg_files_path);
|
||||
List<String> urls = await uploadFiles(path, files);
|
||||
package.photoUrls = urls;
|
||||
@@ -284,26 +284,26 @@ class PackageModel extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateReceiving(User user, Package package, List<File?> files,
|
||||
Future<void> updateReceiving(User? user, Package package, List<File?> files,
|
||||
List<String?> deletedUrls) async {
|
||||
if (user != null) {
|
||||
package.fcsID = user.fcsID;
|
||||
}
|
||||
if (deletedUrls != null) {
|
||||
if (deletedUrls.isNotEmpty) {
|
||||
for (String? url in deletedUrls) {
|
||||
package.photoUrls.remove(url);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> uploadedURL = [];
|
||||
if (files != null) {
|
||||
if (files.isNotEmpty) {
|
||||
var count =
|
||||
(package.photoUrls.length) + files.length - (deletedUrls.length);
|
||||
|
||||
if (count > uploadPhotoLimit)
|
||||
throw Exception("Exceed number of file upload");
|
||||
|
||||
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
|
||||
package.photoUrls = package.photoUrls;
|
||||
String path = Path.join(pkg_files_path);
|
||||
uploadedURL = await uploadFiles(path, files);
|
||||
uploadedURL.forEach((url) {
|
||||
@@ -329,20 +329,20 @@ class PackageModel extends BaseModel {
|
||||
|
||||
Future<void> updateProcessing(
|
||||
Package package, List<File?> files, List<String?> deletedUrls) async {
|
||||
if (deletedUrls != null) {
|
||||
if (deletedUrls.isNotEmpty) {
|
||||
for (String? url in deletedUrls) {
|
||||
package.photoUrls.remove(url);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> uploadedURL = [];
|
||||
if (files != null) {
|
||||
if (files.isNotEmpty) {
|
||||
var count =
|
||||
(package.photoUrls.length) + files.length - (deletedUrls.length);
|
||||
|
||||
if (count > uploadPhotoLimit)
|
||||
throw Exception("Exceed number of file upload");
|
||||
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
|
||||
package.photoUrls = package.photoUrls;
|
||||
String path = Path.join(pkg_files_path);
|
||||
uploadedURL = await uploadFiles(path, files);
|
||||
uploadedURL.forEach((url) {
|
||||
|
||||
Reference in New Issue
Block a user