mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Fixed race condition in search
This commit is contained in:
parent
b161da1c1a
commit
1eae55e3bb
@ -5,7 +5,7 @@ author = {
|
|||||||
"email":"maloja@krateng.dev",
|
"email":"maloja@krateng.dev",
|
||||||
"github": "krateng"
|
"github": "krateng"
|
||||||
}
|
}
|
||||||
version = 2,6,0
|
version = 2,6,1
|
||||||
versionstr = ".".join(str(n) for n in version)
|
versionstr = ".".join(str(n) for n in version)
|
||||||
links = {
|
links = {
|
||||||
"pypi":"malojaserver",
|
"pypi":"malojaserver",
|
||||||
|
@ -145,6 +145,7 @@ replaceartist 여자친구 GFriend GFriend
|
|||||||
|
|
||||||
# Girl's Generation
|
# Girl's Generation
|
||||||
replaceartist 소녀시대 Girls' Generation
|
replaceartist 소녀시대 Girls' Generation
|
||||||
|
replaceartist SNSD Girls' Generation
|
||||||
|
|
||||||
# Apink
|
# Apink
|
||||||
replaceartist A Pink Apink
|
replaceartist A Pink Apink
|
||||||
@ -162,6 +163,11 @@ replacetitle 달라달라 (DALLA DALLA) Dalla Dalla
|
|||||||
# K/DA
|
# K/DA
|
||||||
belongtogether K/DA
|
belongtogether K/DA
|
||||||
|
|
||||||
|
# 2NE1
|
||||||
|
countas CL 2NE1
|
||||||
|
|
||||||
|
# WJSN
|
||||||
|
replaceartist Cosmic Girls WJSN
|
||||||
|
|
||||||
# Popular Remixes
|
# Popular Remixes
|
||||||
artistintitle Areia Remix Areia
|
artistintitle Areia Remix Areia
|
||||||
|
Can't render this file because it has a wrong number of fields in line 5.
|
@ -1,4 +1,4 @@
|
|||||||
|
var searches = []
|
||||||
|
|
||||||
function search(searchfield) {
|
function search(searchfield) {
|
||||||
txt = searchfield.value;
|
txt = searchfield.value;
|
||||||
@ -7,6 +7,7 @@ function search(searchfield) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
xhttp = new XMLHttpRequest();
|
xhttp = new XMLHttpRequest();
|
||||||
|
searches.push(xhttp)
|
||||||
xhttp.onreadystatechange = searchresult
|
xhttp.onreadystatechange = searchresult
|
||||||
xhttp.open("GET","/api/search?max=5&query=" + encodeURIComponent(txt), true);
|
xhttp.open("GET","/api/search?max=5&query=" + encodeURIComponent(txt), true);
|
||||||
xhttp.send();
|
xhttp.send();
|
||||||
@ -45,8 +46,9 @@ const oneresult = html_to_fragment(resulthtml).firstElementChild;
|
|||||||
|
|
||||||
|
|
||||||
function searchresult() {
|
function searchresult() {
|
||||||
if (this.readyState == 4 && this.status == 200 && document.getElementById("searchinput").value != "") {
|
if (this.readyState == 4 && this.status == 200 && document.getElementById("searchinput").value != "" && searches.includes(this)) {
|
||||||
// checking if field is empty in case we get an old result coming in that would overwrite our cleared result window
|
// any older searches are now rendered irrelevant
|
||||||
|
while (searches[0] != this) { searches.splice(0,1) }
|
||||||
var result = JSON.parse(this.responseText);
|
var result = JSON.parse(this.responseText);
|
||||||
var artists = result["artists"].slice(0,5)
|
var artists = result["artists"].slice(0,5)
|
||||||
var tracks = result["tracks"].slice(0,5)
|
var tracks = result["tracks"].slice(0,5)
|
||||||
|
1
maloja/thirdparty/musicbrainz.py
vendored
1
maloja/thirdparty/musicbrainz.py
vendored
@ -57,7 +57,6 @@ class MusicBrainz(MetadataInterface):
|
|||||||
return self.metadata_parse_response_track(data)
|
return self.metadata_parse_response_track(data)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
raise
|
|
||||||
return None
|
return None
|
||||||
finally:
|
finally:
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
Loading…
Reference in New Issue
Block a user