Skip to content

Commit

Permalink
persist labels across restarts
Browse files Browse the repository at this point in the history
  • Loading branch information
ech0-de committed Jun 2, 2023
1 parent 85805ee commit f49e621
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async function shortenDescription(text, options) {
return output.filter(e => e).slice(0, options.maxLines + 1).join('\n');
}

window.addEventListener('DOMContentLoaded', () => {
window.addEventListener('DOMContentLoaded', async () => {
document.getElementById('logo').src = `data:image/svg+xml;base64,${btoa(logo)}`;
const printerSelect = document.getElementById('setting-printer');
const input = document.getElementById('scan');
Expand Down Expand Up @@ -158,6 +158,7 @@ window.addEventListener('DOMContentLoaded', () => {
}
document.querySelector('iframe').src = '';
document.querySelector('iframe').style.display = 'none';
localStorage.setItem('queue', JSON.stringify(queue));
});

const printNow = async (small=false) => {
Expand Down Expand Up @@ -190,8 +191,6 @@ window.addEventListener('DOMContentLoaded', () => {
}
}));

console.log(item);

content.push({
columnGap: mm2pt(.5),
margins: 0,
Expand Down Expand Up @@ -297,7 +296,7 @@ window.addEventListener('DOMContentLoaded', () => {
}

if (yaml.serial) {
yaml.description = `S/N: ${yaml.serial}\n${yaml.description}`;
yaml.description = `Seriennummer: ${yaml.serial}\n${yaml.description}`;
}

const item = document.createElement('li');
Expand Down Expand Up @@ -348,8 +347,18 @@ window.addEventListener('DOMContentLoaded', () => {
title: title,
yaml: yaml
};
localStorage.setItem('queue', JSON.stringify(queue));
};

try {
const restored = JSON.parse(localStorage.getItem('queue'));
for (const id of Object.keys(restored)) {
await queueItem(id);
}
} catch {
// ignore
}

input.addEventListener('blur', () => input.focus());

input.addEventListener('keydown', async (evt) => {
Expand Down

0 comments on commit f49e621

Please sign in to comment.