detect if a query is hash, get rid of radio buttons

This commit is contained in:
Zlatin Balevsky
2019-06-16 08:09:51 +01:00
parent 05a1ccd3d8
commit 13767d58f2
4 changed files with 13 additions and 21 deletions

View File

@ -34,7 +34,6 @@ Basically any non-gui non-cli user interface
### Small Items
* Detect if a query is hash, get rid of radio buttons
* Detect if router is dead and show warning or exit
* Wrapper of some kind for in-place upgrades
* Download file sequentially

View File

@ -49,9 +49,20 @@ class MainFrameController {
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
model.results[uuid.toString()] = group
boolean hashSearch = false
byte [] root = null
if (search.length() == 44 && search.indexOf(" ") < 0) {
try {
root = Base64.decode(search)
hashSearch = true
} catch (Exception e) {
// not a hash search
}
}
def searchEvent
if (model.hashSearch) {
searchEvent = new SearchEvent(searchHash : Base64.decode(search), uuid : uuid)
if (hashSearch) {
searchEvent = new SearchEvent(searchHash : root, uuid : uuid)
} else {
// this can be improved a lot
def replaced = search.toLowerCase().trim().replaceAll(Constants.SPLIT_PATTERN, " ")
@ -175,16 +186,6 @@ class MainFrameController {
markTrust("trusted-table", TrustLevel.NEUTRAL, model.trusted)
}
@ControllerAction
void keywordSearch() {
model.hashSearch = false
}
@ControllerAction
void hashSearch() {
model.hashSearch = true
}
void unshareSelectedFiles() {
println "unsharing selected files"
}

View File

@ -56,8 +56,6 @@ class MainFrameModel {
def trusted = []
def distrusted = []
boolean hashSearch
@Observable int connections
@Observable String me
@Observable boolean searchButtonsEnabled

View File

@ -90,12 +90,6 @@ class MainFrameView {
}
panel( constraints: BorderLayout.EAST) {
panel {
buttonGroup(id : "searchButtonGroup")
radioButton(text : "Keywords", selected : true, buttonGroup : searchButtonGroup, keywordSearchAction)
radioButton(text : "Hash", selected : false, buttonGroup : searchButtonGroup, hashSearchAction)
}
button(text: "Search", searchAction)
}
}