mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-08 11:48:26 -04:00
Do not check for Electron updates if app installed from MS Store
This commit is contained in:
parent
f566cb8566
commit
c9868b806b
@ -3,6 +3,12 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
// A regular expression that matches the hash of the Kiwix publisher on the Microsoft Store (CN=0A5438F5-EEA6-4300-9B77-E45BBD148885)
|
||||
// If the app is installed from the Store rather than from the signed GitHub release, we need to disable update checking
|
||||
const regexpInstalledFromMicrosoftStore = /_mc3511b08yc0e/;
|
||||
console.log('[Preload] Is app installed from Microsoft Store? ' + (process.windowsStore && regexpInstalledFromMicrosoftStore.test(window.location.pathname) ? 'Yes' : 'No'));
|
||||
console.log('Window location: ' + window.location.pathname + '\nStore publisher hash: ' + regexpInstalledFromMicrosoftStore);
|
||||
|
||||
// DEV: TO SUPPORT ELECTRON ^12 YOU WILL NEED THIS
|
||||
const { ipcRenderer, contextBridge } = require('electron');
|
||||
const { open, read, close, stat, readdir } = require('fs');
|
||||
@ -22,6 +28,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
checkForUpdates: function () {
|
||||
ipcRenderer.send('check-updates');
|
||||
},
|
||||
isMicrosoftStoreApp: process.windowsStore && regexpInstalledFromMicrosoftStore.test(window.location.pathname),
|
||||
on: function (event, callback) {
|
||||
ipcRenderer.on(event, function (_, data) {
|
||||
callback(data);
|
||||
|
@ -918,15 +918,16 @@ if (window.electronAPI) {
|
||||
// Check for GitHub and Electron updates
|
||||
var updateCheck = document.getElementById('updateCheck');
|
||||
params.isUWPStoreApp = /UWP/.test(params.appType) && Windows.ApplicationModel && Windows.ApplicationModel.Package &&
|
||||
!/Association.Kiwix/.test(Windows.ApplicationModel.Package.current.id.publisher);
|
||||
!/Association.Kiwix/.test(Windows.ApplicationModel.Package.current.id.publisher) || electronAPI && electronAPI.isMicrosotStoreApp;
|
||||
// If Internet access is allowed, or it's a UWP Store app, or it's HTML5 (i.e., not Electron/NWJS or UWP) ...
|
||||
if (params.allowInternetAccess || params.isUWPStoreApp || /HTML5/.test(params.appType)) {
|
||||
updateCheck.style.display = 'none'; // ... hide the update check link
|
||||
if (params.isUWPStoreApp) console.debug('Hiding update check link because this is a UWP Store app.');
|
||||
}
|
||||
// Function to check for updates from GitHub
|
||||
function checkUpdateServer() {
|
||||
if (!params.allowInternetAccess || params.upgradeNeeded) {
|
||||
console.log('The GitHub update check was blocked because ' + (params.upgradeNeeded ? 'a PWA upgrade is needed.' : 'the user has not allowed Internet access.'));
|
||||
console.warn('The GitHub update check was blocked because ' + (params.upgradeNeeded ? 'a PWA upgrade is needed.' : 'the user has not allowed Internet access.'));
|
||||
return;
|
||||
}
|
||||
// If it's plain HTML5 (not Electron/NWJS or UWP), don't check for updates
|
||||
|
Loading…
x
Reference in New Issue
Block a user