|
@@ -60,9 +60,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
var titleCurrentFolder = NCBrandOptions.shared.brand
|
|
|
var serverUrl = ""
|
|
|
// -------------------------------------------------------------
|
|
|
-
|
|
|
- private let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
-
|
|
|
+
|
|
|
private var emptyDataSet: NCEmptyDataSet?
|
|
|
|
|
|
private let keyLayout = NCGlobal.shared.layoutViewMove
|
|
@@ -99,6 +97,8 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
private var shares: [tableShare]?
|
|
|
|
|
|
private let refreshControl = UIRefreshControl()
|
|
|
+
|
|
|
+ private var activeAccount: tableAccount!
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
@@ -106,6 +106,8 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
self.navigationController?.navigationBar.prefersLargeTitles = true
|
|
|
self.navigationController?.presentationController?.delegate = self
|
|
|
|
|
|
+ activeAccount = NCManageDatabase.shared.getAccountActive()
|
|
|
+
|
|
|
// Cell
|
|
|
collectionView.register(UINib.init(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell")
|
|
|
collectionView.register(UINib.init(nibName: "NCGridCell", bundle: nil), forCellWithReuseIdentifier: "gridCell")
|
|
@@ -178,12 +180,12 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
|
|
|
// set the serverUrl
|
|
|
if serverUrl == "" {
|
|
|
- serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
|
|
|
+ serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, account: activeAccount.account)
|
|
|
}
|
|
|
|
|
|
// get auto upload folder
|
|
|
autoUploadFileName = NCManageDatabase.shared.getAccountAutoUploadFileName()
|
|
|
- autoUploadDirectory = NCManageDatabase.shared.getAccountAutoUploadDirectory(urlBase: appDelegate.urlBase, account: appDelegate.account)
|
|
|
+ autoUploadDirectory = NCManageDatabase.shared.getAccountAutoUploadDirectory(urlBase: activeAccount.urlBase, account: activeAccount.account)
|
|
|
|
|
|
(layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: keyLayout,serverUrl: serverUrl)
|
|
|
gridLayout.itemForLine = CGFloat(itemForLine)
|
|
@@ -196,7 +198,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
|
|
|
loadDatasource(withLoadFolder: true)
|
|
|
|
|
|
- shares = NCManageDatabase.shared.getTableShares(account: appDelegate.account, serverUrl: serverUrl)
|
|
|
+ shares = NCManageDatabase.shared.getTableShares(account: activeAccount.account, serverUrl: serverUrl)
|
|
|
}
|
|
|
|
|
|
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
|
@@ -464,7 +466,7 @@ extension NCSelect: UICollectionViewDataSource {
|
|
|
var isMounted = false
|
|
|
|
|
|
// Download preview
|
|
|
- NCOperationQueue.shared.downloadThumbnail(metadata: metadata, urlBase: appDelegate.urlBase, view: collectionView, indexPath: indexPath)
|
|
|
+ NCOperationQueue.shared.downloadThumbnail(metadata: metadata, urlBase: activeAccount.urlBase, view: collectionView, indexPath: indexPath)
|
|
|
|
|
|
isShare = metadata.permissions.contains(NCGlobal.shared.permissionShared) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionShared)
|
|
|
isMounted = metadata.permissions.contains(NCGlobal.shared.permissionMounted) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionMounted)
|
|
@@ -521,7 +523,7 @@ extension NCSelect: UICollectionViewDataSource {
|
|
|
cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
|
|
|
|
|
|
let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
|
|
|
- let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
|
|
|
+ let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account, lockServerUrl))
|
|
|
|
|
|
// Local image: offline
|
|
|
if tableDirectory != nil && tableDirectory!.offline {
|
|
@@ -569,13 +571,13 @@ extension NCSelect: UICollectionViewDataSource {
|
|
|
} else {
|
|
|
cell.imageShared.image = NCBrandColor.cacheImages.canShare
|
|
|
}
|
|
|
- if metadata.ownerId.count > 0 && metadata.ownerId != appDelegate.userId {
|
|
|
- let fileNameUser = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + metadata.ownerId + ".png"
|
|
|
+ if metadata.ownerId.count > 0 && metadata.ownerId != activeAccount.userId {
|
|
|
+ let fileNameUser = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(activeAccount.user, urlBase: activeAccount.urlBase)) + "-" + metadata.ownerId + ".png"
|
|
|
if FileManager.default.fileExists(atPath: fileNameUser) {
|
|
|
cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
|
|
|
} else {
|
|
|
NCCommunication.shared.downloadAvatar(userId: metadata.ownerId, fileNameLocalPath: fileNameUser, size: NCGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
|
|
|
- if errorCode == 0 && account == self.appDelegate.account {
|
|
|
+ if errorCode == 0 && account == self.activeAccount.account {
|
|
|
cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
|
|
|
}
|
|
|
}
|
|
@@ -646,7 +648,7 @@ extension NCSelect: UICollectionViewDataSource {
|
|
|
}
|
|
|
|
|
|
let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
|
|
|
- let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
|
|
|
+ let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account, lockServerUrl))
|
|
|
|
|
|
// Local image: offline
|
|
|
if tableDirectory != nil && tableDirectory!.offline {
|
|
@@ -736,17 +738,17 @@ extension NCSelect {
|
|
|
if includeDirectoryE2EEncryption {
|
|
|
|
|
|
if includeImages {
|
|
|
- predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND (directory == true OR typeFile == 'image')", appDelegate.account, serverUrl)
|
|
|
+ predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND (directory == true OR typeFile == 'image')", activeAccount.account, serverUrl)
|
|
|
} else {
|
|
|
- predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND directory == true", appDelegate.account, serverUrl)
|
|
|
+ predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND directory == true", activeAccount.account, serverUrl)
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if includeImages {
|
|
|
- predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND e2eEncrypted == false AND (directory == true OR typeFile == 'image')", appDelegate.account, serverUrl)
|
|
|
+ predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND e2eEncrypted == false AND (directory == true OR typeFile == 'image')", activeAccount.account, serverUrl)
|
|
|
} else {
|
|
|
- predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND e2eEncrypted == false AND directory == true", appDelegate.account, serverUrl)
|
|
|
+ predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND e2eEncrypted == false AND directory == true", activeAccount.account, serverUrl)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -759,7 +761,7 @@ extension NCSelect {
|
|
|
self.refreshControl.endRefreshing()
|
|
|
}
|
|
|
|
|
|
- let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account,serverUrl))
|
|
|
+ let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account,serverUrl))
|
|
|
richWorkspaceText = directory?.richWorkspace
|
|
|
|
|
|
collectionView.reloadData()
|
|
@@ -767,7 +769,7 @@ extension NCSelect {
|
|
|
|
|
|
func createFolder(with fileName: String) {
|
|
|
|
|
|
- NCNetworking.shared.createFolder(fileName: fileName, serverUrl: serverUrl, account: appDelegate.account, urlBase: appDelegate.urlBase) { (errorCode, errorDescription) in
|
|
|
+ NCNetworking.shared.createFolder(fileName: fileName, serverUrl: serverUrl, account: activeAccount.account, urlBase: activeAccount.urlBase) { (errorCode, errorDescription) in
|
|
|
|
|
|
if errorCode == 0 {
|
|
|
self.loadDatasource(withLoadFolder: true)
|
|
@@ -782,7 +784,7 @@ extension NCSelect {
|
|
|
networkInProgress = true
|
|
|
collectionView.reloadData()
|
|
|
|
|
|
- NCNetworking.shared.readFolder(serverUrl: serverUrl, account: appDelegate.account) { (_, _, _, _, _, errorCode, errorDescription) in
|
|
|
+ NCNetworking.shared.readFolder(serverUrl: serverUrl, account: activeAccount.account) { (_, _, _, _, _, errorCode, errorDescription) in
|
|
|
if errorCode != 0 {
|
|
|
NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
|
|
|
}
|