diff options
| author | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2024-03-07 20:59:26 +0000 |
|---|---|---|
| committer | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2024-03-07 20:59:26 +0000 |
| commit | 9f44e87b092e9149c47466e4578f794fe4376524 (patch) | |
| tree | cab65045dac8cd99d48a225c731d09c4a000320b /src/db.js | |
| parent | 2b8fea0fd0b514b5ca4349185bf4dfb4455d5875 (diff) | |
Does stuff
Diffstat (limited to 'src/db.js')
| -rw-r--r-- | src/db.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/db.js b/src/db.js new file mode 100644 index 0000000..145b144 --- /dev/null +++ b/src/db.js @@ -0,0 +1,29 @@ +// Ideally, we should write to a file and read it at app start in case of crashes. +// An actual SQL database would probably be overkill. + +/** @type Array<{ name: string, number: string }> */ +const subscriptions = []; + +/** + * @param {string} number + * @param {string} name + */ +export function subscribe(number, name) { + subscriptions.push({ name, number }); +} + +/** + * @param {string} number + */ +export function isSubscribed(number) { + return subscriptions.some(s => s.number == number); +} + +export function getSubscriptions() { + /** @type Array<{ name: string, number: string }> */ + const clone = []; + for (const subscription of subscriptions) { + clone.push({ ...subscription }); + } + return clone; +}
\ No newline at end of file |
