mirror of
https://github.com/SuperBFG7/ympd
synced 2025-01-27 01:14:53 +00:00
feat: Refresh queue card only if queue_version changed
This commit is contained in:
parent
bccda91585
commit
2fd94d734c
@ -141,7 +141,7 @@
|
||||
</div>
|
||||
|
||||
<div class="table-responsive-md">
|
||||
<table id="QueueList" class="table table-hover table-sm">
|
||||
<table id="QueueList" class="table table-hover table-sm" data-version="">
|
||||
<col class="tblnum"/>
|
||||
<col class="tbltitle"/>
|
||||
<col class="tblartist"/>
|
||||
|
@ -756,8 +756,13 @@ function parseState(obj) {
|
||||
function getQueue() {
|
||||
if (app.current.search.length >= 2)
|
||||
sendAPI({"cmd": "MPD_API_SEARCH_QUEUE", "data": {"mpdtag":app.current.filter, "offset":app.current.page, "searchstr": app.current.search}}, parseQueue);
|
||||
else
|
||||
sendAPI({"cmd": "MPD_API_GET_QUEUE", "data": {"offset": app.current.page}}, parseQueue);
|
||||
else {
|
||||
var queue_version = document.getElementById('QueueList').getAttribute('data-version');
|
||||
if (last_state && queue_version != last_state.data.queue_version)
|
||||
sendAPI({"cmd": "MPD_API_GET_QUEUE", "data": {"offset": app.current.page}}, parseQueue);
|
||||
else
|
||||
document.getElementById('QueueList').classList.remove('opacity05');
|
||||
}
|
||||
}
|
||||
|
||||
function parseQueue(obj) {
|
||||
@ -772,7 +777,9 @@ function parseQueue(obj) {
|
||||
document.getElementById('panel-heading-queue').innerText = '';
|
||||
|
||||
var nrItems = obj.data.length;
|
||||
var tbody = document.getElementById(app.current.app + 'List').getElementsByTagName('tbody')[0];
|
||||
var table = document.getElementById(app.current.app + 'List');
|
||||
table.setAttribute('data-version', obj.queue_version);
|
||||
var tbody = table.getElementsByTagName('tbody')[0];
|
||||
var tr = tbody.getElementsByTagName('tr');
|
||||
for (var i = 0; i < nrItems; i ++) {
|
||||
if (tr[i])
|
||||
|
@ -798,11 +798,12 @@ int mympd_put_queue(char *buffer, unsigned int offset) {
|
||||
mpd_entity_free(entity);
|
||||
}
|
||||
|
||||
len += json_printf(&out, "],totalTime: %d, totalEntities: %d, offset: %d, returnedEntities: %d }",
|
||||
len += json_printf(&out, "],totalTime: %d, totalEntities: %d, offset: %d, returnedEntities: %d, queue_version: %d }",
|
||||
totalTime,
|
||||
entity_count,
|
||||
offset,
|
||||
entities_returned
|
||||
entities_returned,
|
||||
mpd.queue_version
|
||||
);
|
||||
|
||||
if (len > MAX_SIZE) fprintf(stderr,"Buffer truncated\n");
|
||||
|
Loading…
Reference in New Issue
Block a user