mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 02:26:00 +01:00
Use the global cache-hash for settings and textures .json requests
This commit is contained in:
parent
b437684dbb
commit
b02b91d3bb
@ -154,6 +154,9 @@ export class BlueMapApp {
|
||||
await this.mapViewer.switchMap(null);
|
||||
oldMaps.forEach(map => map.dispose());
|
||||
|
||||
// load user settings
|
||||
await this.loadUserSettings();
|
||||
|
||||
// load maps
|
||||
this.maps = await this.loadMaps();
|
||||
for (let map of this.maps) {
|
||||
@ -180,9 +183,6 @@ export class BlueMapApp {
|
||||
if(this.updateLoop) clearTimeout(this.updateLoop);
|
||||
this.updateLoop = setTimeout(this.update, 1000);
|
||||
|
||||
// load user settings
|
||||
await this.loadUserSettings();
|
||||
|
||||
// save user settings
|
||||
this.saveUserSettings();
|
||||
|
||||
@ -303,7 +303,7 @@ export class BlueMapApp {
|
||||
let map = new BlueMapMap(mapId, this.dataUrl + mapId + "/", this.loadBlocker, this.mapViewer.events);
|
||||
maps.push(map);
|
||||
|
||||
await map.loadSettings()
|
||||
await map.loadSettings(this.mapViewer.tileCacheHash)
|
||||
.catch(error => {
|
||||
alert(this.events, `Failed to load settings for map '${map.data.id}':` + error, "warning");
|
||||
});
|
||||
|
@ -105,8 +105,8 @@ export class Map {
|
||||
load(hiresVertexShader, hiresFragmentShader, lowresVertexShader, lowresFragmentShader, uniforms, tileCacheHash = 0) {
|
||||
this.unload()
|
||||
|
||||
let settingsPromise = this.loadSettings();
|
||||
let textureFilePromise = this.loadTexturesFile();
|
||||
let settingsPromise = this.loadSettings(tileCacheHash);
|
||||
let textureFilePromise = this.loadTexturesFile(tileCacheHash);
|
||||
|
||||
this.lowresMaterial = this.createLowresMaterial(lowresVertexShader, lowresFragmentShader, uniforms);
|
||||
|
||||
@ -134,8 +134,8 @@ export class Map {
|
||||
* Loads the settings of this map
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
loadSettings() {
|
||||
return this.loadSettingsFile()
|
||||
loadSettings(tileCacheHash) {
|
||||
return this.loadSettingsFile(tileCacheHash)
|
||||
.then(worldSettings => {
|
||||
this.data.name = worldSettings.name ? worldSettings.name : this.data.name;
|
||||
|
||||
@ -223,13 +223,13 @@ export class Map {
|
||||
* Loads the settings.json file for this map
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
loadSettingsFile() {
|
||||
loadSettingsFile(tileCacheHash) {
|
||||
return new Promise((resolve, reject) => {
|
||||
alert(this.events, `Loading settings for map '${this.data.id}'...`, "fine");
|
||||
|
||||
let loader = new FileLoader();
|
||||
loader.setResponseType("json");
|
||||
loader.load(this.data.settingsUrl + "?" + generateCacheHash(),
|
||||
loader.load(this.data.settingsUrl + "?" + tileCacheHash,
|
||||
resolve,
|
||||
() => {},
|
||||
() => reject(`Failed to load the settings.json for map: ${this.data.id}`)
|
||||
@ -241,13 +241,13 @@ export class Map {
|
||||
* Loads the textures.json file for this map
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
loadTexturesFile() {
|
||||
loadTexturesFile(tileCacheHash) {
|
||||
return new Promise((resolve, reject) => {
|
||||
alert(this.events, `Loading textures for map '${this.data.id}'...`, "fine");
|
||||
|
||||
let loader = new FileLoader();
|
||||
loader.setResponseType("json");
|
||||
loader.load(this.data.texturesUrl + "?" + generateCacheHash(),
|
||||
loader.load(this.data.texturesUrl + "?" + tileCacheHash,
|
||||
resolve,
|
||||
() => {},
|
||||
() => reject(`Failed to load the textures.json for map: ${this.data.id}`)
|
||||
|
Loading…
Reference in New Issue
Block a user