get rid of manual library refresh, switch to LinkedHashSet for all files, properly clean up intermediate nodes in the filtered tree

pull/62/head
Zlatin Balevsky 2021-06-12 09:30:16 +01:00
parent 65b20a9f93
commit 29e002f8f1
No known key found for this signature in database
GPG Key ID: A72832072D525E41
3 changed files with 10 additions and 17 deletions

View File

@ -478,7 +478,6 @@ class MainFrameController {
core.eventBus.publish(new FileUnsharedEvent(unsharedFile : sf))
}
core.eventBus.publish(new RefreshLibraryEvent())
}
@ControllerAction

View File

@ -104,7 +104,7 @@ class MainFrameModel {
volatile String filter
volatile Filterer filterer
boolean treeVisible = true
private final List<SharedFile> allSharedFiles = Collections.synchronizedList(new ArrayList<>())
private final Set<SharedFile> allSharedFiles = Collections.synchronizedSet(new LinkedHashSet<>())
def shared
TreeModel sharedTree
DefaultMutableTreeNode allFilesTreeRoot, treeRoot
@ -299,7 +299,6 @@ class MainFrameModel {
core.eventBus.register(UIMessageReadEvent.class, this)
core.eventBus.register(MessageSentEvent.class, this)
core.eventBus.register(MessageFolderLoadingEvent.class, this)
core.eventBus.register(RefreshLibraryEvent.class, this)
core.muOptions.watchedKeywords.each {
@ -563,7 +562,14 @@ class MainFrameModel {
throw new IllegalStateException()
otherNode = next
}
otherNode.removeFromParent()
while(true) {
def parent = otherNode.getParent()
otherNode.removeFromParent()
if (parent.getChildCount() == 0) {
otherNode = parent
} else
break
}
}
List<File> unshared = new ArrayList<>()
@ -585,16 +591,10 @@ class MainFrameModel {
File unsharedRoot = unshared.get( unshared.size() -1 )
core.eventBus.publish(new DirectoryUnsharedEvent(directory : unsharedRoot))
}
}
}
}
}
void onRefreshLibraryEvent(RefreshLibraryEvent e) {
runInsideUIAsync {
view.refreshSharedFiles()
}
}
void onUploadEvent(UploadEvent e) {
runInsideUIAsync {
UploaderWrapper wrapper = null

View File

@ -1,6 +0,0 @@
package com.muwire.gui
import com.muwire.core.Event
class RefreshLibraryEvent extends Event {
}