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