mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
core: remove unused methods
This commit is contained in:
@@ -315,7 +315,7 @@ export class Attachments implements ICollection {
|
||||
if (!data) return;
|
||||
|
||||
return (
|
||||
outputType === "base64"
|
||||
outputType === "base64" && typeof data === "string"
|
||||
? dataurl.fromObject({
|
||||
mimeType: attachment.mimeType,
|
||||
data
|
||||
|
||||
@@ -20,10 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import { ICollection } from "./collection";
|
||||
import { getId } from "../utils/id";
|
||||
import { getContentFromData } from "../content-types";
|
||||
import { ResolveHashes } from "../content-types/tiptap";
|
||||
import { isCipher } from "../database/crypto";
|
||||
import {
|
||||
Attachment,
|
||||
ContentItem,
|
||||
ContentType,
|
||||
UnencryptedContentItem,
|
||||
@@ -254,24 +252,6 @@ export class Content implements ICollection {
|
||||
// );
|
||||
// }
|
||||
|
||||
insertMedia(contentItem: UnencryptedContentItem) {
|
||||
return this.insert(contentItem, async (hashes) => {
|
||||
const sources: Record<string, string> = {};
|
||||
for (const hash of hashes) {
|
||||
const src = await this.db.attachments.read(hash, "base64");
|
||||
if (!src) continue;
|
||||
sources[hash] = src;
|
||||
}
|
||||
return sources;
|
||||
});
|
||||
}
|
||||
|
||||
insertPlaceholders(contentItem: UnencryptedContentItem, placeholder: string) {
|
||||
return this.insert(contentItem, async (hashes) => {
|
||||
return Object.fromEntries(hashes.map((h) => [h, placeholder]));
|
||||
});
|
||||
}
|
||||
|
||||
async downloadMedia(
|
||||
groupId: string,
|
||||
contentItem: { type: ContentType; data: string },
|
||||
@@ -280,12 +260,9 @@ export class Content implements ICollection {
|
||||
const content = getContentFromData(contentItem.type, contentItem.data);
|
||||
if (!content) return contentItem;
|
||||
contentItem.data = await content.insertMedia(async (hashes) => {
|
||||
const attachments: Attachment[] = [];
|
||||
for (const hash of hashes) {
|
||||
const attachment = await this.db.attachments.attachment(hash);
|
||||
if (!attachment) continue;
|
||||
attachments.push(attachment);
|
||||
}
|
||||
const attachments = await this.db.attachments.all
|
||||
.where((eb) => eb("attachments.hash", "in", hashes))
|
||||
.items();
|
||||
|
||||
await this.db.fs().queueDownloads(
|
||||
attachments.map((a) => ({
|
||||
@@ -302,7 +279,7 @@ export class Content implements ICollection {
|
||||
attachment.hash,
|
||||
getOutputType(attachment)
|
||||
);
|
||||
if (!src) continue;
|
||||
if (!src || typeof src !== "string") continue;
|
||||
sources[attachment.hash] = src;
|
||||
}
|
||||
return sources;
|
||||
@@ -310,16 +287,6 @@ export class Content implements ICollection {
|
||||
return contentItem;
|
||||
}
|
||||
|
||||
private async insert(
|
||||
contentItem: UnencryptedContentItem,
|
||||
getData: ResolveHashes
|
||||
) {
|
||||
const content = getContentFromData(contentItem.type, contentItem.data);
|
||||
if (!content) return contentItem;
|
||||
contentItem.data = await content.insertMedia(getData);
|
||||
return contentItem;
|
||||
}
|
||||
|
||||
async removeAttachments(id: string, hashes: string[]) {
|
||||
const contentItem = await this.get(id);
|
||||
if (!contentItem || isCipher(contentItem.data)) return;
|
||||
|
||||
Reference in New Issue
Block a user