Skip to content

Commit

Permalink
Merge pull request #1797 from barijaona/foldersTree
Browse files Browse the repository at this point in the history
Re-write folders order in database when they are automatically sorted
  • Loading branch information
barijaona authored Aug 27, 2024
2 parents cdc274f + 993deb1 commit 979b31e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Vienna/Sources/Main window/FoldersTree.m
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,16 @@ -(BOOL)loadTree:(NSArray *)listOfFolders rootNode:(TreeNode *)node
{
Folder * folder;
if ([Preferences standardPreferences].foldersTreeSortMethod != VNAFolderSortManual) {
// make sure chaining is coherent…
NSInteger siblingsCount = listOfFolders.count;
[[Database sharedManager] setFirstChild:((Folder *)listOfFolders[0]).itemId forFolder:node.nodeId];
for (NSInteger i=0 ; i < siblingsCount-1 ; i++) {
NSInteger current = ((Folder *)listOfFolders[i]).itemId;
NSInteger next = ((Folder *)listOfFolders[i+1]).itemId;
[[Database sharedManager] setNextSibling:next forFolder:current];
}
[[Database sharedManager] setNextSibling:0 forFolder:((Folder *)listOfFolders[siblingsCount-1]).itemId];
// …then attach the different nodes
for (folder in listOfFolders) {
NSInteger itemId = folder.itemId;
NSArray * listOfSubFolders = [[[Database sharedManager] arrayOfFolders:itemId] sortedArrayUsingSelector:@selector(folderNameCompare:)];
Expand Down

0 comments on commit 979b31e

Please sign in to comment.