logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

db.js (1092B)


  1. export default () => new Promise((resolve, reject) => {
  2. // ServiceWorker is required to synchronize the login state.
  3. // Microsoft Edge 17 does not support getAll according to:
  4. // Catalog of standard and vendor APIs across browsers - Microsoft Edge Development
  5. // https://developer.microsoft.com/en-us/microsoft-edge/platform/catalog/?q=specName%3Aindexeddb
  6. if (!('caches' in self && 'getAll' in IDBObjectStore.prototype)) {
  7. reject();
  8. return;
  9. }
  10. const request = indexedDB.open('mastodon');
  11. request.onerror = reject;
  12. request.onsuccess = ({ target }) => resolve(target.result);
  13. request.onupgradeneeded = ({ target }) => {
  14. const accounts = target.result.createObjectStore('accounts', { autoIncrement: true });
  15. const statuses = target.result.createObjectStore('statuses', { autoIncrement: true });
  16. accounts.createIndex('id', 'id', { unique: true });
  17. accounts.createIndex('moved', 'moved');
  18. statuses.createIndex('id', 'id', { unique: true });
  19. statuses.createIndex('account', 'account');
  20. statuses.createIndex('reblog', 'reblog');
  21. };
  22. });