Compare commits

...

4 Commits

Author SHA1 Message Date
GeekCorner
09f924093e
Merge f551a064ce into 7e95771957 2023-11-12 19:19:03 -03:00
Daniel Scalzi
7e95771957
Remove dependence on node crypto module in landing.js 2023-11-11 23:37:59 -05:00
GeekCorner
f551a064ce
Update uicore.js 2022-05-18 15:40:54 +02:00
GeekCorner
84c34e84ab
Update electron-builder.yml 2022-05-18 15:38:44 +02:00
3 changed files with 83 additions and 89 deletions

View File

@ -2,8 +2,6 @@
* Script for landing.ejs * Script for landing.ejs
*/ */
// Requirements // Requirements
const cp = require('child_process')
const crypto = require('crypto')
const { URL } = require('url') const { URL } = require('url')
const { const {
MojangRestAPI, MojangRestAPI,
@ -800,6 +798,16 @@ function showNewsAlert(){
$(newsButtonAlert).fadeIn(250) $(newsButtonAlert).fadeIn(250)
} }
async function digestMessage(str) {
const msgUint8 = new TextEncoder().encode(str)
const hashBuffer = await crypto.subtle.digest('SHA-1', msgUint8)
const hashArray = Array.from(new Uint8Array(hashBuffer))
const hashHex = hashArray
.map((b) => b.toString(16).padStart(2, '0'))
.join('')
return hashHex
}
/** /**
* Initialize News UI. This will load the news and prepare * Initialize News UI. This will load the news and prepare
* the UI accordingly. * the UI accordingly.
@ -807,13 +815,11 @@ function showNewsAlert(){
* @returns {Promise.<void>} A promise which resolves when the news * @returns {Promise.<void>} A promise which resolves when the news
* content has finished loading and transitioning. * content has finished loading and transitioning.
*/ */
function initNews(){ async function initNews(){
return new Promise((resolve, reject) => {
setNewsLoading(true) setNewsLoading(true)
let news = {} const news = await loadNews()
loadNews().then(news => {
newsArr = news?.articles || null newsArr = news?.articles || null
@ -821,11 +827,9 @@ function initNews(){
// News Loading Failed // News Loading Failed
setNewsLoading(false) setNewsLoading(false)
$('#newsErrorLoading').fadeOut(250, () => { await $('#newsErrorLoading').fadeOut(250).promise()
$('#newsErrorFailed').fadeIn(250, () => { await $('#newsErrorFailed').fadeIn(250).promise()
resolve()
})
})
} else if(newsArr.length === 0) { } else if(newsArr.length === 0) {
// No News Articles // No News Articles
setNewsLoading(false) setNewsLoading(false)
@ -837,18 +841,15 @@ function initNews(){
}) })
ConfigManager.save() ConfigManager.save()
$('#newsErrorLoading').fadeOut(250, () => { await $('#newsErrorLoading').fadeOut(250).promise()
$('#newsErrorNone').fadeIn(250, () => { await $('#newsErrorNone').fadeIn(250).promise()
resolve()
})
})
} else { } else {
// Success // Success
setNewsLoading(false) setNewsLoading(false)
const lN = newsArr[0] const lN = newsArr[0]
const cached = ConfigManager.getNewsCache() const cached = ConfigManager.getNewsCache()
let newHash = crypto.createHash('sha1').update(lN.content).digest('hex') let newHash = await digestMessage(lN.content)
let newDate = new Date(lN.date) let newDate = new Date(lN.date)
let isNew = false let isNew = false
@ -895,18 +896,12 @@ function initNews(){
document.getElementById('newsNavigateRight').onclick = () => { switchHandler(true) } document.getElementById('newsNavigateRight').onclick = () => { switchHandler(true) }
document.getElementById('newsNavigateLeft').onclick = () => { switchHandler(false) } document.getElementById('newsNavigateLeft').onclick = () => { switchHandler(false) }
await $('#newsErrorContainer').fadeOut(250).promise()
$('#newsErrorContainer').fadeOut(250, () => {
displayArticle(newsArr[0], 1) displayArticle(newsArr[0], 1)
$('#newsContent').fadeIn(250, () => { await $('#newsContent').fadeIn(250).promise()
resolve()
})
})
} }
})
})
} }
/** /**

View File

@ -49,7 +49,7 @@ if(!isDev){
loggerAutoUpdater.info('New update available', info.version) loggerAutoUpdater.info('New update available', info.version)
if(process.platform === 'darwin'){ if(process.platform === 'darwin'){
info.darwindownload = `https://github.com/dscalzi/HeliosLauncher/releases/download/v${info.version}/Helios-Launcher-setup-${info.version}${process.arch === 'arm64' ? '-arm64' : '-x64'}.dmg` info.darwindownload = `https://github.com/dscalzi/HeliosLauncher/releases/download/v${info.version}/Helios-Launcher-setup.dmg`
showUpdateUI(info) showUpdateUI(info)
} }

View File

@ -31,9 +31,8 @@ mac:
target: target:
- target: 'dmg' - target: 'dmg'
arch: arch:
- 'x64' - 'universal'
- 'arm64' artifactName: '${productName}-setup-${version}.${ext}'
artifactName: '${productName}-setup-${version}-${arch}.${ext}'
category: 'public.app-category.games' category: 'public.app-category.games'
# Linux Configuration # Linux Configuration