Add factory reset button on error screen

This commit is contained in:
JannisX11 2024-03-02 23:07:25 +01:00
parent a56fe01a51
commit f7f7c00205
3 changed files with 13 additions and 6 deletions

View File

@ -49,6 +49,7 @@
<div>An error occurred while loading Blockbench</div>
<div id="loading_error_detail" style="color: var(--color-subtle_text);"></div>
<button onclick="isApp ? Blockbench.reload() : window.location.reload(true)" class="large" style="margin-right: auto; margin-left: auto;">Reload</button>
<button onclick="factoryResetAndReload()" class="large" style="margin-right: auto; margin-left: auto;">Factory Reset</button>
<button onclick="window.close()" class="large" style="margin-right: auto; margin-left: auto;">Quit</button>
</div>
<script>

View File

@ -489,12 +489,7 @@ const MenuBar = {
}},
'reset_layout',
{name: 'menu.help.developer.reset_storage', icon: 'fas.fa-hdd', click: () => {
if (confirm(tl('menu.help.developer.reset_storage.confirm'))) {
localStorage.clear()
Blockbench.addFlag('no_localstorage_saving')
console.log('Cleared Local Storage')
window.location.reload(true)
}
factoryResetAndReload();
}},
{name: 'menu.help.developer.unlock_projects', id: 'unlock_projects', icon: 'vpn_key', condition: () => ModelProject.all.find(project => project.locked), click() {
ModelProject.all.forEach(project => project.locked = false);

View File

@ -279,6 +279,17 @@ const TickUpdates = {
}
}
function factoryResetAndReload() {
let lang_key = 'menu.help.developer.reset_storage.confirm';
let result = window.confirm((window.tl && tl(lang_key) != lang_key) ? tl(lang_key) : 'Are you sure you want to reset Blockbench to factory settings? This will delete all custom settings, keybindings and installed plugins.');
if (result) {
localStorage.clear();
Blockbench.addFlag('no_localstorage_saving');
console.log('Cleared Local Storage');
window.location.reload(true);
}
}
const documentReady = new Promise((resolve, reject) => {
$(document).ready(function() {
resolve()