From 3f97f74082ab3e236ac0e15e374fd1a99ff687b9 Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Sat, 8 Jan 2022 14:22:22 +0100 Subject: [PATCH] Fix plugin caching issue Fix start screen caching issue Fix backgrounds not working in some display mode slots --- js/interface/start_screen.js | 6 +++++- js/plugin_loader.js | 27 +++++++++++++++++---------- js/preview/preview.js | 18 ++++++++---------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/js/interface/start_screen.js b/js/interface/start_screen.js index 17c7953..d884a85 100644 --- a/js/interface/start_screen.js +++ b/js/interface/start_screen.js @@ -236,7 +236,11 @@ onVueSetup(function() { addStartScreenSection('new_version', data.new_version) })*/ - var news_call = $.getJSON('https://web.blockbench.net/content/news.json') + var news_call = $.ajax({ + cache: false, + url: 'https://web.blockbench.net/content/news.json', + dataType: 'json' + }); Promise.all([news_call, documentReady]).then((data) => { if (!data || !data[0]) return; data = data[0]; diff --git a/js/plugin_loader.js b/js/plugin_loader.js index f4635e4..e903b76 100644 --- a/js/plugin_loader.js +++ b/js/plugin_loader.js @@ -390,16 +390,23 @@ if (isApp) { } Plugins.loading_promise = new Promise((resolve, reject) => { - $.getJSON('https://cdn.jsdelivr.net/gh/JannisX11/blockbench-plugins/plugins.json?'+Math.round(Math.random()*99), function(data) { - Plugins.json = data - resolve(); - Plugins.loading_promise.resolved = true; - }).fail(function() { - console.log('Could not connect to plugin server') - $('#plugin_available_empty').text('Could not connect to plugin server') - resolve(); - Plugins.loading_promise.resolved = true; - }) + + $.ajax({ + cache: false, + url: 'https://cdn.jsdelivr.net/gh/JannisX11/blockbench-plugins/plugins.json', + dataType: 'json', + success(data) { + Plugins.json = data; + resolve(); + Plugins.loading_promise.resolved = true; + }, + error() { + console.log('Could not connect to plugin server') + $('#plugin_available_empty').text('Could not connect to plugin server') + resolve(); + Plugins.loading_promise.resolved = true; + } + }); }) $.getJSON('https://blckbn.ch/api/stats/plugins?weeks=2', data => { diff --git a/js/preview/preview.js b/js/preview/preview.js index 7842355..92632e8 100644 --- a/js/preview/preview.js +++ b/js/preview/preview.js @@ -1240,18 +1240,16 @@ class Preview { if (display_mode) { var id = displayReferenceObjects.active.id if (id == 'monitor' ||id == 'bow') { - this.background = canvas_scenes.monitor + return this.background = canvas_scenes.monitor } else if (['inventory_nine', 'inventory_full', 'hud'].includes(id)) { - this.background = canvas_scenes[id] - } else { - this.background = canvas_scenes.normal + return this.background = canvas_scenes[id] } - } else if (this.angle !== null) { - this.background = Project && Project.backgrounds['ortho_'+this.angle] - } else { - this.background = Project && Project.backgrounds.normal } - return this.background + if (this.angle === null) { + return this.background = Project && Project.backgrounds.normal; + } else { + return this.background = Project && Project.backgrounds['ortho_'+this.angle]; + } } loadBackground() { this.getBackground() @@ -1423,7 +1421,7 @@ class Preview { changeDisplaySkin() }}, 'preview_checkerboard', - {id: 'background', icon: 'wallpaper', name: 'menu.preview.background', children(preview) { + {id: 'background', icon: 'wallpaper', name: 'menu.preview.background', condition: (preview) => preview.getBackground(), children(preview) { var has_background = !!preview.background.image function applyBackground(image) { preview.background.image = image;