mirror of
https://github.com/dualshock-tools/dualshock-tools.github.io.git
synced 2026-03-01 11:19:54 +03:00
Show a warning on the Connect screen if the changes were not saved
This commit is contained in:
@@ -386,6 +386,11 @@
|
|||||||
<div id="lastConnected" class="gap-2">
|
<div id="lastConnected" class="gap-2">
|
||||||
<span class="text-muted"><i class="fas fa-history"></i> <span class="ds-i18n">Last connected</span>:</span>
|
<span class="text-muted"><i class="fas fa-history"></i> <span class="ds-i18n">Last connected</span>:</span>
|
||||||
<span id="lastConnectedInfo"></span>
|
<span id="lastConnectedInfo"></span>
|
||||||
|
<div id="lastConnectedWarning" style="display: none;">
|
||||||
|
<p class="text-danger" style="margin-top: 8px; margin-bottom: 0;">
|
||||||
|
<i class="fas fa-regular fa-triangle-exclamation"></i> <span class="ds-i18n">This controller has unsaved changes that will be lost when the controller is rebooted.</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
17
js/core.js
17
js/core.js
@@ -295,15 +295,14 @@ async function continue_connection({data, device}) {
|
|||||||
// Save controller info to local storage
|
// Save controller info to local storage
|
||||||
const lastConnectedInfo = {
|
const lastConnectedInfo = {
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
timestamp: new Date().toISOString()
|
timestamp: new Date().toISOString(),
|
||||||
|
serialNumber: await controllerInstance.getSerialNumber(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extract info from infoItems
|
// Extract info from infoItems
|
||||||
if (info.infoItems && Array.isArray(info.infoItems)) {
|
if (info.infoItems && Array.isArray(info.infoItems)) {
|
||||||
for (const item of info.infoItems) {
|
for (const item of info.infoItems) {
|
||||||
if (item.key === l("Serial Number")) {
|
if (item.key === l("Board Model")) {
|
||||||
lastConnectedInfo.serialNumber = item.value;
|
|
||||||
} else if (item.key === l("Board Model")) {
|
|
||||||
lastConnectedInfo.boardModel = item.value;
|
lastConnectedInfo.boardModel = item.value;
|
||||||
} else if (item.key === l("Color")) {
|
} else if (item.key === l("Color")) {
|
||||||
lastConnectedInfo.color = item.value;
|
lastConnectedInfo.color = item.value;
|
||||||
@@ -428,6 +427,16 @@ function updateLastConnectedInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$infoDiv.text(text);
|
$infoDiv.text(text);
|
||||||
|
|
||||||
|
if (info.serialNumber) {
|
||||||
|
const storageKey = `changes_${info.serialNumber}`;
|
||||||
|
const savedChangesState = localStorage.getItem(storageKey);
|
||||||
|
const hasChanges = savedChangesState ? JSON.parse(savedChangesState) : false;
|
||||||
|
|
||||||
|
const $warning = $("#lastConnectedWarning");
|
||||||
|
$warning.toggle(hasChanges);
|
||||||
|
}
|
||||||
|
|
||||||
$lastConnected.show();
|
$lastConnected.show();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error parsing last connected info:", error);
|
console.error("Error parsing last connected info:", error);
|
||||||
|
|||||||
Reference in New Issue
Block a user