Browse Source

Added fallback cache rendered for desktop

TC pushbot 5 4 years ago
parent
commit
8d8d2fcebe
1 changed files with 35 additions and 2 deletions
  1. 35 2
      web/desktop.system

+ 35 - 2
web/desktop.system

@@ -5263,7 +5263,7 @@
                                         $(imageContainer).parent().append(`<img src="${data.IconPath}" style="position: absolute; right: 0px; top: ${topOffset}px; width: ${iconSize}px; height: ${iconSize}px; pointer-events:none;"></img>`);
                                         $(imageContainer).parent().append(`<img src="${data.IconPath}" style="position: absolute; right: 0px; top: ${topOffset}px; width: ${iconSize}px; height: ${iconSize}px; pointer-events:none;"></img>`);
                                     }
                                     }
                                 }
                                 }
-                            })
+                            });
                         }
                         }
                     }
                     }
                 });
                 });
@@ -5274,10 +5274,43 @@
             };
             };
 
 
             thumbRenderWebSocket.onerror = function(error) {
             thumbRenderWebSocket.onerror = function(error) {
-                console.log(error);
+                console.log("Cannot connect to WebSocket cache renderer. Falling back to AJAX request");
+                startFallbackThumbnailLoader();
             };
             };
         }
         }
 
 
+        function startFallbackThumbnailLoader(){
+                $(".launchIcon").each(function(){
+                    let fd = JSON.parse(decodeURIComponent($(this).attr("filedata"))) 
+                    let filepath = fd.Filepath;
+                    let targetDOM = $(this);
+                    $.ajax({
+                        url: "system/file_system/loadThumbnail",
+                        data: {vpath: filepath},
+                        success: function(data){
+                            if (data.error == undefined && data != undefined && data != ""){
+                                let imageContainer = $(targetDOM).find(".launchIconImage");
+                                imageContainer.attr("src","data:image/jpg;base64," + data);
+                                imageContainer.css("padding", "0.6em"); 
+                                
+                                $.ajax({
+                                    url: "system/modules/getDefault",
+                                    data: {opr: "launch", ext: fd.Ext},
+                                    method: "GET",
+                                    success: function(data){
+                                        if (data.error == undefined){
+                                            let iconSize = 20;
+                                            let topOffset = $(imageContainer).height() - iconSize/2 + 2;
+                                            $(imageContainer).parent().append(`<img src="${data.IconPath}" style="position: absolute; right: 0px; top: ${topOffset}px; width: ${iconSize}px; height: ${iconSize}px; pointer-events:none;"></img>`);
+                                        }
+                                    }
+                                });
+                            }      
+                        }
+                    })
+                });
+            }
+
 
 
         function openfm() {
         function openfm() {
             //Open file explorer on desktop
             //Open file explorer on desktop