(job: ImageJob)
| 37 | * We strip the previewUrl because Object URLs expire on refresh. |
| 38 | */ |
| 39 | export const saveJobToDb = async (job: ImageJob): Promise<void> => { |
| 40 | try { |
| 41 | const db = await openDB(); |
| 42 | const transaction = db.transaction(STORE_NAME, 'readwrite'); |
| 43 | const store = transaction.objectStore(STORE_NAME); |
| 44 | // Remove previewUrl |
| 45 | const jobToSave = {...job}; |
| 46 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 47 | delete (jobToSave as any).previewUrl; |
| 48 | |
| 49 | store.put(jobToSave); |
| 50 | } catch (e) { |
| 51 | console.error('Failed to save job to DB', e); |
| 52 | } |
| 53 | }; |
| 54 | |
| 55 | export const deleteJobFromDb = async (id: string): Promise<void> => { |
| 56 | try { |
no test coverage detected