Must use the same db.
This commit is contained in:
parent
4ec3775659
commit
a7d5a976ca
@ -8,7 +8,7 @@ document.querySelector('#fInput').onchange = async evt => {
|
||||
};
|
||||
|
||||
window.__DEV__ = true;
|
||||
window.imagedb = getDatabase('gallery-images');
|
||||
window.db = getDatabase();
|
||||
|
||||
image.imported.subscribe(refresh);
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import pica from 'pica/dist/pica';
|
||||
|
||||
import { generateAttachmentUrl } from '../services/db.js';
|
||||
import { imported, find, update, addAttachment, DB_NAME } from '../data/image.js';
|
||||
import { generateAttachmentUrl, getDatabase } from '../services/db.js';
|
||||
import { imported, find, update, addAttachment } from '../data/image.js';
|
||||
|
||||
export function maxLinearSize(width, height, max) {
|
||||
const ratio = width / height;
|
||||
@ -57,7 +57,7 @@ export async function generateThumbnailForImage(id) {
|
||||
const mimetype = attachment.content_type;
|
||||
const { width, height } = maxLinearSize(doc.width, doc.height, 320);
|
||||
const resizedBlob = await resizeImage(attachment.data, mimetype, width, height);
|
||||
const url = generateAttachmentUrl(DB_NAME, id, 'thumbnail');
|
||||
const url = generateAttachmentUrl(getDatabase().name, id, 'thumbnail');
|
||||
|
||||
await addAttachment(doc, 'thumbnail', resizedBlob);
|
||||
await update(doc._id, {
|
||||
|
||||
@ -6,8 +6,7 @@ import { sha256 } from '../utils/crypto.js';
|
||||
import { blobToArrayBuffer, deepAssign } from '../utils/conversion.js';
|
||||
import { Event, backgroundTask } from '../utils/event.js';
|
||||
|
||||
export const DB_NAME = 'gallery-images';
|
||||
const db = getDatabase(DB_NAME);
|
||||
const db = getDatabase();
|
||||
const PROCESS_PREFIX = 'importing';
|
||||
|
||||
// Events
|
||||
@ -123,7 +122,7 @@ const processImportables = backgroundTask(async function _processImportables() {
|
||||
flash: !!tags.Flash,
|
||||
ISO: tags.ISO,
|
||||
attachmentUrls: {
|
||||
image: generateAttachmentUrl(DB_NAME, id, 'image')
|
||||
image: generateAttachmentUrl(db.name, id, 'image')
|
||||
},
|
||||
gps: {
|
||||
latitude: tags.GPSLatitude,
|
||||
|
||||
@ -9,7 +9,7 @@ export function generateAttachmentUrl(dbName, docId, attachmentKey) {
|
||||
}
|
||||
|
||||
const dbs = new Map();
|
||||
export function getDatabase(name) {
|
||||
export function getDatabase(name = 'gallery') {
|
||||
if (!dbs.has(name)) {
|
||||
dbs.set(name, new PouchDB(name));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user