From 7b103470b4940c1cbdf4dc56849b79f47fc16740 Mon Sep 17 00:00:00 2001
From: derouet2018 <tristan.derouet@gmail.com>
Date: Sun, 21 Nov 2021 22:51:46 +0100
Subject: [PATCH] Finally fixed multiple id command by using query type of add
 in lektor

---
 common/lkt.js     | 21 +++------------------
 instance/index.js |  2 +-
 main.js           |  4 ++--
 3 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/common/lkt.js b/common/lkt.js
index c13707a..a1fc6a3 100644
--- a/common/lkt.js
+++ b/common/lkt.js
@@ -395,24 +395,9 @@ class LktClient {
         return LktClient.__execSimple(`password hashire\nupdate`)
     }
 
-    static commandQueueAddMulId(IdList) {
-        var command;
-        var promize = new Promise(()=>null);
-        var size = 5;
-         var arrayOfArrays = [];
-        for (var i=0; i<IdList.length; i+=size) {
-            arrayOfArrays.push(IdList.slice(i,i+size));
-        }
-        arrayOfArrays.forEach(idbatch => {
-            command = "addid"
-            if(idbatch) {
-                idbatch.forEach(id => {
-                    command = command + " " + id;
-                });
-                promize = promize.then(resolve => setTimeout(resolve, 4000)).then(LktClient.__execSimple(command));
-            }
-        });
-        return null;
+    static commandQueueAddSearch(search) {
+        search = search.replace(/ /g,"%");
+        return LktClient.__execSimple(`add query://%${search}%`);
     }
 
     static errorStatus(error) {
diff --git a/instance/index.js b/instance/index.js
index bbb10ae..a737e69 100644
--- a/instance/index.js
+++ b/instance/index.js
@@ -111,7 +111,7 @@ window.onload = () => {
     switchQP.onclick = ()=>switchQueuePlaylist();
 
     document.getElementById('addResearchToQueue').onclick = ()=>{
-        ipcRenderer.send('add-kara-queue-multiple-id', karaDBIDList);
+        ipcRenderer.send('add-kara-queue-search-result',`${$('#filterInput').val()}`);
     };
 
 
diff --git a/main.js b/main.js
index 0f11a51..aba816c 100644
--- a/main.js
+++ b/main.js
@@ -305,8 +305,8 @@ ipcMain.on('get-playlist-data', (event, playlist) => {
     }
 });
 
-ipcMain.on('add-kara-queue-multiple-id', (event, IdList) => {
-    lkt.commandQueueAddMulId(IdList);
+ipcMain.on('add-kara-queue-search-result', (event, search) => {
+    lkt.commandQueueAddSearch(search);
 });
 
 
-- 
GitLab