@@ -10,34 +10,41 @@ import NextcloudKit
10
10
11
11
extension NCShareExtension : UICollectionViewDelegate {
12
12
func collectionView( _ collectionView: UICollectionView , didSelectItemAt indexPath: IndexPath ) {
13
- self . dataSource. getMetadata ( indexPath: indexPath) { metadata in
14
- guard let metadata else { return self . showAlert ( description: " _invalid_url_ " ) }
13
+ Task {
14
+ guard let tblAccount = self . extensionData. getTblAccoun ( ) ,
15
+ let metadata = self . dataSource. getMetadata ( indexPath: indexPath) else {
16
+ return self . showAlert ( description: " _invalid_url_ " )
17
+ }
15
18
let serverUrl = self . utilityFileSystem. stringAppendServerUrl ( metadata. serverUrl, addFileName: metadata. fileName)
16
- if metadata. e2eEncrypted && !NCKeychain( ) . isEndToEndEnabled ( account: self . session. account) {
19
+
20
+ if metadata. e2eEncrypted && !NCKeychain( ) . isEndToEndEnabled ( account: tblAccount. account) {
17
21
self . showAlert ( title: " _info_ " , description: " _e2e_goto_settings_for_enable_ " )
18
22
}
19
- let capabilities = NKCapabilities . shared. getCapabilitiesBlocking ( for: self . session . account)
23
+ let capabilities = NKCapabilities . shared. getCapabilitiesBlocking ( for: tblAccount . account)
20
24
21
- if let fileNameError = FileNameValidator . checkFileName ( metadata. fileNameView, account: self . session . account, capabilities: capabilities) {
25
+ if let fileNameError = FileNameValidator . checkFileName ( metadata. fileNameView, account: tblAccount . account, capabilities: capabilities) {
22
26
self . present ( UIAlertController . warning ( message: " \( fileNameError. errorDescription) \( NSLocalizedString ( " _please_rename_file_ " , comment: " " ) ) " ) , animated: true )
23
27
return
24
28
}
25
29
26
30
self . serverUrl = serverUrl
27
- self . reloadDatasource ( withLoadFolder: true )
28
31
self . setNavigationBar ( navigationTitle: metadata. fileNameView)
32
+
33
+ await self . reloadData ( )
34
+ await self . loadFolder ( )
29
35
}
30
36
}
31
37
32
38
func collectionView( _ collectionView: UICollectionView , viewForSupplementaryElementOfKind kind: String , at indexPath: IndexPath ) -> UICollectionReusableView {
33
39
if kind == UICollectionView . elementKindSectionHeader {
40
+ let session = self . extensionData. getSession ( )
34
41
guard let header = collectionView. dequeueReusableSupplementaryView ( ofKind: kind, withReuseIdentifier: " sectionFirstHeaderEmptyData " , for: indexPath) as? NCSectionFirstHeaderEmptyData else { return NCSectionFirstHeaderEmptyData ( ) }
35
42
if self . dataSourceTask? . state == . running {
36
43
header. emptyImage. image = utility. loadImage ( named: " wifi " , colors: [ NCBrandColor . shared. getElement ( account: session. account) ] )
37
44
header. emptyTitle. text = NSLocalizedString ( " _request_in_progress_ " , comment: " " )
38
45
header. emptyDescription. text = " "
39
46
} else {
40
- header. emptyImage. image = NCImageCache . shared. getFolder ( account: self . session. account)
47
+ header. emptyImage. image = NCImageCache . shared. getFolder ( account: session. account)
41
48
header. emptyTitle. text = NSLocalizedString ( " _files_no_folders_ " , comment: " " )
42
49
header. emptyDescription. text = " "
43
50
}
@@ -116,6 +123,8 @@ extension NCShareExtension: UICollectionViewDataSource {
116
123
var isShare = false
117
124
var isMounted = false
118
125
let permissions = NCPermissions ( )
126
+ let session = self . extensionData. getSession ( )
127
+
119
128
if let metadataFolder = metadataFolder {
120
129
isShare = metadata. permissions. contains ( permissions. permissionShared) && !metadataFolder. permissions. contains ( permissions. permissionShared)
121
130
isMounted = metadata. permissions. contains ( permissions. permissionMounted) && !metadataFolder. permissions. contains ( permissions. permissionMounted)
@@ -159,8 +168,12 @@ extension NCShareExtension: UITableViewDelegate {
159
168
}
160
169
161
170
func tableView( _ tableView: UITableView , didSelectRowAt indexPath: IndexPath ) {
162
- guard !uploadStarted else { return }
171
+ guard !uploadStarted else {
172
+ return
173
+ }
163
174
let fileName = filesName [ indexPath. row]
175
+ let session = self . extensionData. getSession ( )
176
+
164
177
showRenameFileDialog ( named: fileName, account: session. account)
165
178
}
166
179
}
@@ -171,10 +184,16 @@ extension NCShareExtension: UITableViewDataSource {
171
184
}
172
185
173
186
func tableView( _ tableView: UITableView , cellForRowAt indexPath: IndexPath ) -> UITableViewCell {
174
- guard let cell = tableView. dequeueReusableCell ( withIdentifier: " Cell " , for: indexPath) as? NCShareCell else { return UITableViewCell ( ) }
187
+ guard let cell = tableView. dequeueReusableCell ( withIdentifier: " Cell " , for: indexPath) as? NCShareCell else {
188
+ return UITableViewCell ( )
189
+ }
190
+
175
191
let fileName = filesName [ indexPath. row]
192
+ let session = self . extensionData. getSession ( )
193
+
176
194
cell. setup ( fileName: fileName, iconName: " " , account: session. account)
177
195
cell. delegate = self
196
+
178
197
return cell
179
198
}
180
199
}
0 commit comments