Fix launch cache sanitization and progress layout
This commit is contained in:
@@ -7,6 +7,10 @@ const DEFAULT_REMOTE_DISTRO_URL = 'https://cdn.mysticred.space/launcher/distribu
|
||||
let remoteDistroUrl = DEFAULT_REMOTE_DISTRO_URL
|
||||
let activeApi = createApi(remoteDistroUrl)
|
||||
|
||||
function distributionsDiffer(left, right){
|
||||
return JSON.stringify(left) !== JSON.stringify(right)
|
||||
}
|
||||
|
||||
function sanitizeServer(rawServer){
|
||||
const nextServer = {
|
||||
...rawServer
|
||||
@@ -51,6 +55,37 @@ function buildDistribution(api, rawDistribution){
|
||||
}
|
||||
|
||||
function patchDistributionApi(api){
|
||||
const originalPullRemote = api.pullRemote.bind(api)
|
||||
const originalPullLocal = api.pullLocal.bind(api)
|
||||
const originalWriteDistributionToDisk = api.writeDistributionToDisk.bind(api)
|
||||
|
||||
api.writeDistributionToDisk = async function(distribution){
|
||||
const sanitizedDistribution = sanitizeDistribution(distribution)
|
||||
await originalWriteDistributionToDisk(sanitizedDistribution)
|
||||
}
|
||||
|
||||
api.pullRemote = async function(){
|
||||
const response = await originalPullRemote()
|
||||
if(response?.data != null){
|
||||
response.data = sanitizeDistribution(response.data)
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
api.pullLocal = async function(){
|
||||
const rawDistribution = await originalPullLocal()
|
||||
if(rawDistribution == null){
|
||||
return rawDistribution
|
||||
}
|
||||
|
||||
const sanitizedDistribution = sanitizeDistribution(rawDistribution)
|
||||
if(distributionsDiffer(rawDistribution, sanitizedDistribution)){
|
||||
await originalWriteDistributionToDisk(sanitizedDistribution)
|
||||
}
|
||||
|
||||
return sanitizedDistribution
|
||||
}
|
||||
|
||||
api.getDistribution = async function(){
|
||||
if(this.rawDistribution == null || this.distribution == null){
|
||||
const rawDistribution = await this.loadDistribution()
|
||||
|
||||
Reference in New Issue
Block a user