Fix detection of single track albums in the queue 240/head
authorfittacunt <a5441252@nwytg.net>
Wed, 13 Mar 2019 21:11:35 +0000 (18:11 -0300)
committerfittacunt <a5441252@nwytg.net>
Wed, 13 Mar 2019 21:11:35 +0000 (18:11 -0300)
Fixes #224

app/app.js
app/public/js/frontend.js

index f21e4e8fc3d8fc75da5f61c1d91aef4743c4878a..4312fa54a5feffbe72fb9d7f31840e1f6f07d5b5 100644 (file)
@@ -484,6 +484,7 @@ io.sockets.on('connection', function (s) {
                                        failed: 0,
                                        queueId: `id${Math.random().toString(36).substring(2)}`,
                                        id: `${track.id}:${data.bitrate}`,
+                                       urlId: data.id,
                                        bitrate: data.bitrate+"",
                                        type: 'track',
                                        settings: data.settings || {},
index 7854093e7842d88ca9c8df418fbb3fa187c65f89..787f8242f2f7c80caf9aa77ab600474e3a4d145e 100644 (file)
@@ -1040,7 +1040,7 @@ function addToQueue(url, forceBitrate=null) {
 function alreadyInQueue(id, bitrate) {
        var alreadyInQueue = false
        $('#tab_downloads_table_downloads').find('tbody').find('tr').each(function () {
-               if ($(this).data('deezerid') == `${id}:${bitrate}`) {
+               if ($(this).data('deezerid') == `${id}:${bitrate}` || $(this).data('urlid') == id) {
                        alreadyInQueue = true
                        return false
                }
@@ -1051,8 +1051,16 @@ function alreadyInQueue(id, bitrate) {
 function addObjToQueue(data){
        var tableBody = $('#tab_downloads_table_downloads').find('tbody')
 
+       // If we're downloading a single track album, we create a `data-urlid` property
+       // containing the album ID that's the same on the URL. Example:
+       //
+       // https://www.deezer.com/us/album/6389674 --> data-urlid is 6389674
+       //
+       // That way we can properly detect if a single track albums in the queue. See issue #224
+       var url_id = ('urlId' in data) ? data.urlId : ''
+
        $(tableBody).append(
-                       `<tr id="${data.queueId}" data-deezerid="${data.id}">
+                       `<tr id="${data.queueId}" data-deezerid="${data.id}" data-urlid="${url_id}">
                        <td class="queueTitle">${data.name}</td>
                        <td class="queueSize">${data.size}</td>
                        <td class="queueDownloaded">${data.downloaded}</td>