all repos

onasty @ 9c8b9eae5400bed303e3892d640786b0cb0b3554

a one-time notes service

onasty/web/src/interop.js (view raw)

Smirnov Oleksandr Smirnov Oleksandr
ss2316544@gmail.com
refactor(web): make use of types for handling auth (#137)..., 11 months ago
1
import "./styles.css";
2
3
export const flags = (_) => {
4
  return {
5
    access_token: JSON.parse(window.localStorage.access_token || "null"),
6
    refresh_token: JSON.parse(window.localStorage.refresh_token || "null"),
7
  };
8
};
9
10
export const onReady = ({ app }) => {
11
  if (app.ports?.sendToLocalStorage) {
12
    app.ports.sendToLocalStorage.subscribe(({ key, value }) => {
13
      window.localStorage[key] = JSON.stringify(value);
14
    });
15
  }
16
};