Преглед на файлове

Patched Music module thumbnail loading bug (tmp)

Toby Chui преди 3 години
родител
ревизия
29235a6543
променени са 1 файла, в които са добавени 26 реда и са изтрити 17 реда
  1. 26 17
      web/Music/index.html

+ 26 - 17
web/Music/index.html

@@ -1167,6 +1167,7 @@
 			//This might be a file from dropdown list. use listid instead
 			id = $(object).parent().attr('listid');
 		}
+		
 
 	    updateMiniPlayerUI(displayName,info,id);
 
@@ -1212,7 +1213,6 @@
 			let thisFileItemID = $(this).attr("id");
 			let rawname = JSON.parse(decodeURIComponent($(this).attr("rawname")));
 			
-
 			let realVpath = filepath.split("=");
 			realVpath.shift();
 			realVpath = realVpath.join("=");
@@ -1975,21 +1975,6 @@
 		});
 	}
 	
-
-	
-	function monitorFileChangeForUpload(){
-	    if ($("#interfaceTitle").text() == "Upload"){
-	        //It is still in upload Mode. Continue monitor file change and move them if needed
-	        $.post("listenUploadChange.php",{fileList: JSON.stringify(currentUploadTargetFileList),directory: currentUploadTargetFilepath}).done(function(data){
-	           if (data.includes("ERROR")){
-	               console.log(data);
-	           }
-	        });
-	        setTimeout(monitorFileChangeForUpload,1000);
-	    }
-	}
-	
-	
 	function hideShowMoreMenu(){
 	    $(".showMoreMenus").fadeOut('fast');
 		$("#showmoreUIcover").fadeOut('fast');
@@ -2123,11 +2108,35 @@
 			//Get thumbnail from the current list to prevent re-loading form remote
 			let targetThumbnail = $("#" + (i + 1)).find("img").attr("src");
 			let opacityShowing = "";
-			if ($("#" + (i + 1)).length == 0){
+			if ($("#" + (i + 1)).length == 0 && displayList.length == playingList.length){
 				//Item not exists
 				targetThumbnail = "img/eq.svg";
 				opacityShowing = "opacity: 0.6;"
+			}else if ($("#" + (i + 1)).attr("filepath") != ao_module_utils.objectToAttr(playingList[i][0])){
+				//Display list and playing list mismatch. Get thumbnail from server again and update later
+				targetThumbnail = "img/eq.svg";
+				let realVpath = playingList[i][0].split("=");
+				realVpath.shift();
+				realVpath = realVpath.join("=");
+				let matchingListID = i + 1;
+				let rawFilepath = ao_module_utils.objectToAttr(playingList[i][0]);
+				ao_module_agirun("Music/functions/getThumbnail.js", {
+					file: realVpath,
+				}, function(data){
+					if (data.error !== undefined){
+
+					}else{
+						//Update the playing list to match thumbnail
+						$("#currentPlayingMainList").find(".dropdownList.file").each(function(){
+							if ($(this).attr("filepath") == rawFilepath && $(this).attr("listid") == matchingListID){
+								//This is the one to update
+								$(this).find("img").attr("src","data:image/jpg;base64," + data);
+							}
+						});
+					}
+				});
 			}
+			
 
 			$("#currentPlayingMainList").append(`<div class="dropdownList file item" style="${opacityShowing}" filepath="${ao_module_utils.objectToAttr(playingList[i][0])}" listid="${i + 1}" rawname="${ao_module_utils.objectToAttr(playingList[i][1])}">
 				<div class="ui header selectable" style="margin:0px !important;" onClick="playSongFromDropdownList(this);">