| 1759 | // FF doesn't like Promises (micro-tasks) and IDDB store operations, |
| 1760 | // so we have to do it with callbacks |
| 1761 | function createTransaction(dbInfo, mode, callback, retries) { |
| 1762 | if (retries === undefined) { |
| 1763 | retries = 1; |
| 1764 | } |
| 1765 | |
| 1766 | try { |
| 1767 | var tx = dbInfo.db.transaction(dbInfo.storeName, mode); |
| 1768 | callback(null, tx); |
| 1769 | } catch (err) { |
| 1770 | if (retries > 0 && (!dbInfo.db || err.name === 'InvalidStateError' || err.name === 'NotFoundError')) { |
| 1771 | return Promise$1.resolve().then(function () { |
| 1772 | if (!dbInfo.db || err.name === 'NotFoundError' && !dbInfo.db.objectStoreNames.contains(dbInfo.storeName) && dbInfo.version <= dbInfo.db.version) { |
| 1773 | // increase the db version, to create the new ObjectStore |
| 1774 | if (dbInfo.db) { |
| 1775 | dbInfo.version = dbInfo.db.version + 1; |
| 1776 | } |
| 1777 | // Reopen the database for upgrading. |
| 1778 | return _getUpgradedConnection(dbInfo); |
| 1779 | } |
| 1780 | }).then(function () { |
| 1781 | return _tryReconnect(dbInfo).then(function () { |
| 1782 | createTransaction(dbInfo, mode, callback, retries - 1); |
| 1783 | }); |
| 1784 | })["catch"](callback); |
| 1785 | } |
| 1786 | |
| 1787 | callback(err); |
| 1788 | } |
| 1789 | } |
| 1790 | |
| 1791 | function createDbContext() { |
| 1792 | return { |