Skip to content

Commit b55db94

Browse files
committed
- Add unstage() method in utils.idb class
- #stage implementation in utils.idb class changed to object from arrays - login button gets focused on Home page - added idb-keyval to acknowledgements. reviewed pricing statement
1 parent 21a78f3 commit b55db94

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

app/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ async function inbox (dataArray, fresh=true) {
135135
} else {
136136
/* the element was toggled closed */
137137
// Unaccentuate old messages
138-
// querySelectorAll returns a live nodelist which may change whenever another event handler updates document
139-
// Hence using a shallow copy (Array.from) to isolate
140138
Array.from(tableBody.querySelectorAll('tr.table-primary'))
141139
.forEach((el) => {
142140
el.classList.remove('table-primary');
@@ -503,6 +501,7 @@ function main() {
503501
idb.vals((el1, el2) => el1.time - el2.time).then((dataArray) => inbox(dataArray, false));
504502
} else {
505503
spaShow('login');
504+
document.querySelector('#login').focus({ preventScroll: true, focusVisible: true });
506505
}
507506
};
508507

app/utils.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,24 @@ export class idb {
2020
}
2121

2222
#clearStage () {
23-
this.#staged = { set: [], del: [] };
23+
this.#staged = { set: {}, del: {} };
2424
}
2525

2626
async set (key, val, flush = false) {
2727
if (flush) return idbSet(key, val);
28-
this.#staged.set.push([key, val]);
28+
this.#staged.set[key] = val;
2929
}
3030

31+
unstage (key) {
32+
delete this.#staged.set[key];
33+
delete this.#staged.del[key];
34+
}
35+
36+
// Commits sets after deletes. A key staged for both set and delete gets updated.
3137
async flush () {
3238
const ret = Promise.all([
33-
idbSetMany(this.#staged.set),
34-
idbDelMany(this.#staged.del)
39+
idbDelMany(Object.entries(this.#staged.del)),
40+
idbSetMany(Object.entries(this.#staged.set))
3541
])
3642
this.#clearStage();
3743
return ret;
@@ -45,7 +51,7 @@ export class idb {
4551

4652
async del (key, flush = false) {
4753
if (flush) return idbDel(key);
48-
this.#staged.del.push(key);
54+
this.#staged.del[key] = true;
4955
}
5056

5157
async clear () {

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,15 @@ <h3>About</h3>
8484
<p>You can also check if you are properly receiving form-submissions from <a href="#admin" onclick="spaGoTo('admin');">here</a>.</p>
8585
</details>
8686

87-
<details class="my-2">
87+
<details class="my-2" open>
8888
<summary><h3>Pricing</h3></summary>
8989
This service is free. However, if you find this project useful, <a href="https://buymeacoffee.com/somajitdey">please consider donating towards its survival</a>.
9090
No support is too small. Thank you &#128154;
9191
<br><br>
9292
<p>Note that there are a few tradeoffs for availing this service free of cost &#128513;:</p>
9393
<ol>
94-
<li>1-day data retention</li>
95-
<li>Data retention till first sync; synced data is lost upon page reload</li>
96-
<li>Only support forms with textual data, of total size less than 10KiB, and POSTed as 'application/x-www-form-urlencoded'</li>
94+
<li>Form-data is retained in cloud until synced, for a max period of 1-day</li>
95+
<li>Only supports forms containing textual data, of size less than 10KiB, POSTed as 'application/x-www-form-urlencoded' or 'application/json'</li>
9796
</ol>
9897
</details>
9998

@@ -140,6 +139,7 @@ <h3>About</h3>
140139
<li class="nav-item"><a class="nav-link" href="https://icons8.com/icons">icons8.com</a></li>
141140
<li class="nav-item"><a class="nav-link" href="https://goqr.me/">goQR.me</a></li>
142141
<li class="nav-item"><a class="nav-link" href="https://onesignal.com/web-push">OneSignal</a></li>
142+
<li class="nav-item"><a class="nav-link" href="https://github.com/jakearchibald/idb-keyval">idb-keyval</a></li>
143143
</ul>
144144
</details>
145145

0 commit comments

Comments
 (0)