-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for collections in trash #1013
Open
michalrentka
wants to merge
23
commits into
zotero:master
Choose a base branch
from
michalrentka:collections_trash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,180
−1,307
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
51974bf
Move deleted collections to trash instead of deleting them immediately
michalrentka 29348a7
WIP: trash controller
michalrentka 14f6b45
WIP
michalrentka 6502e39
WIP: Trash items controller
michalrentka a26b399
WIP: refactoring items table view handler & data source
michalrentka 0ced389
WIP: Items controller refactoring to simplify trash controller
michalrentka 182d058
Implementing items actions
michalrentka b94ebe4
WIP: Implementing sorting / filtering
michalrentka 52c0825
WIP: added remaining actions, added download attachment
michalrentka d397c76
WIP: added download/remove download compatibility
michalrentka 487c06f
WIP: Added observing to trash controller
michalrentka 2ec3aa2
last fixes
michalrentka d46abea
Fixed changed comment
michalrentka 6e4560c
Simplified switch
michalrentka c352b0f
Update Zotero/Scenes/Detail/DetailCoordinator.swift
michalrentka 692a451
Update Zotero/Scenes/Detail/Trash/Models/TrashObject.swift
michalrentka 7afe693
Retain library token
michalrentka a44d18c
Fixed typos
michalrentka 97b82f0
Simplified items controller creation
michalrentka a32a8ce
WIP: Refactoring trash state & handler to optimise object loading
michalrentka c4b5855
WIP: finishing trash state data refactoring
michalrentka 0f37522
Bug fixes
michalrentka daa13eb
Fixed broken filters
michalrentka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Zotero/Controllers/Database/Requests/MarkCollectionsAsTrashedDbRequest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// MarkCollectionsAsTrashedDbRequest.swift | ||
// Zotero | ||
// | ||
// Created by Michal Rentka on 18.07.2024. | ||
// Copyright © 2024 Corporation for Digital Scholarship. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import RealmSwift | ||
|
||
struct MarkCollectionsAsTrashedDbRequest: DbRequest { | ||
let keys: [String] | ||
let libraryId: LibraryIdentifier | ||
let trashed: Bool | ||
|
||
var needsWrite: Bool { return true } | ||
|
||
func process(in database: Realm) throws { | ||
let collections = database.objects(RCollection.self).filter(.keys(self.keys, in: self.libraryId)) | ||
collections.forEach { item in | ||
item.trash = trashed | ||
item.changeType = .user | ||
item.changes.append(RObjectChange.create(changes: RCollectionChanges.trash)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems not used anymore, it can be removed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// OrderedDictionary+Utils.swift | ||
// Zotero | ||
// | ||
// Created by Michal Rentka on 19.07.2024. | ||
// Copyright © 2024 Corporation for Digital Scholarship. All rights reserved. | ||
// | ||
|
||
import OrderedCollections | ||
|
||
extension OrderedDictionary { | ||
/// Finds an insertion index for given element in array. The array has to be sorted! Implemented as binary search. | ||
/// - parameter element: Element to be found/inserted | ||
/// - parameter areInIncreasingOrder: sorting function to be used to compare elements in array. | ||
/// - returns: Insertion index into sorted array. | ||
func index(of element: Value, sortedBy areInIncreasingOrder: (Value, Value) -> Bool) -> Int { | ||
var (low, high) = (0, self.count - 1) | ||
while low <= high { | ||
switch (low + high) / 2 { | ||
case let mid where areInIncreasingOrder(element, self.values[mid]): high = mid - 1 | ||
case let mid where areInIncreasingOrder(self.values[mid], element): low = mid + 1 | ||
case let mid: return mid // element found at mid | ||
} | ||
} | ||
return low // element not found, should be inserted here | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to check for
collection.name != response.data.name
and only then update sort name, similar toEditCollectionDbRequest
? May need to do so only for existing collections.