Skip to content

Commit

Permalink
Merge pull request #768 from nextcloud/fix-deleted-shared-items
Browse files Browse the repository at this point in the history
Removed deleted files from shared items view
  • Loading branch information
Ivansss authored Apr 29, 2022
2 parents c827f45 + 5648267 commit 13fd44d
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions NextcloudTalk/RoomSharedItemsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,14 @@ import QuickLook
.getSharedItems(ofType: itemType, fromLastMessageId: currentLastItemId, withLimit: itemLimit,
inRoom: roomToken, for: account) { items, lastItemId, error, _ in
if error == nil, let sharedItems = items as? [NCChatMessage] {
// Remove deleted files
var filteredItems: [NCChatMessage] = []
for message in sharedItems {
if message.systemMessage == "file_shared" && message.file() == nil {continue}
filteredItems.append(message)
}
// Sort received items
let sortedItems = sharedItems.sorted(by: { $0.messageId > $1.messageId })
let sortedItems = filteredItems.sorted(by: { $0.messageId > $1.messageId })
// Set or append items
if self.currentLastItemId > 0 {
self.currentItems.append(contentsOf: sortedItems)
Expand Down Expand Up @@ -252,11 +258,11 @@ import QuickLook

// MARK: - File downloader

func downloadFileForCell(cell: DirectoryTableViewCell, message: NCChatMessage) {
cell.fileParameter = message.file()
func downloadFileForCell(cell: DirectoryTableViewCell, file: NCMessageFileParameter) {
cell.fileParameter = file
let downloader = NCChatFileController()
downloader.delegate = self
downloader.downloadFile(fromMessage: message.file())
downloader.downloadFile(fromMessage: file)
}

func fileControllerDidLoadFile(_ fileController: NCChatFileController, with fileStatus: NCChatFileStatus) {
Expand Down Expand Up @@ -353,11 +359,17 @@ import QuickLook

switch currentItemType {
case kSharedItemTypeMedia, kSharedItemTypeFile, kSharedItemTypeVoice, kSharedItemTypeAudio:
downloadFileForCell(cell: cell, message: message)
if let file = message.file() {
downloadFileForCell(cell: cell, file: file)
}
case kSharedItemTypeLocation:
presentLocation(location: GeoLocationRichObject(from: message.geoLocation()))
if let geoLocation = message.geoLocation() {
presentLocation(location: GeoLocationRichObject(from: geoLocation))
}
case kSharedItemTypeDeckcard, kSharedItemTypeOther:
openLink(link: message.objectShareLink())
if let link = message.objectShareLink() {
openLink(link: link)
}
default:
return
}
Expand Down

0 comments on commit 13fd44d

Please sign in to comment.