mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
fix: content type being set to "content" during sync
this bug broke export/publishing & basically everything that depends on content type to function.
This commit is contained in:
@@ -47,7 +47,7 @@ class Collector {
|
||||
* @param {Array} array
|
||||
* @returns {Array}
|
||||
*/
|
||||
_collect(type, array, isForceSync) {
|
||||
_collect(collectionId, array, isForceSync) {
|
||||
if (!array.length) return [];
|
||||
|
||||
const result = array.reduce((prev, item) => {
|
||||
@@ -60,18 +60,18 @@ class Collector {
|
||||
if (item.localOnly) {
|
||||
prev.push({
|
||||
id: item.id,
|
||||
type,
|
||||
collectionId,
|
||||
deleted: true,
|
||||
dateModified: Date.now(),
|
||||
});
|
||||
} else if (isUnsynced && isSyncable) {
|
||||
prev.push({ ...item, type });
|
||||
prev.push({ ...item, collectionId });
|
||||
}
|
||||
|
||||
return prev;
|
||||
}, []);
|
||||
this.logger.info(
|
||||
`Collected items: ${type} (${result.length}/${array.length})`
|
||||
`Collected items: ${collectionId} (${result.length}/${array.length})`
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,9 @@ class Sync {
|
||||
|
||||
const arrays = data.items.reduce(
|
||||
(arrays, item) => {
|
||||
arrays.types.push(item.type);
|
||||
arrays.types.push(item.collectionId);
|
||||
|
||||
delete item.collectionId;
|
||||
arrays.items.push(item);
|
||||
return arrays;
|
||||
},
|
||||
|
||||
@@ -107,7 +107,11 @@ class Merger {
|
||||
if (deserialized.alg && deserialized.cipher) return deserialized;
|
||||
|
||||
let type = deserialized.type;
|
||||
if (!type && deserialized.data) type = "tiptap";
|
||||
// temporary fix for streetwriters/notesnook#751
|
||||
if (type === "content") {
|
||||
type = "tiptap";
|
||||
deserialized.type = type;
|
||||
}
|
||||
|
||||
if (!migrations[version]) {
|
||||
throw new Error(
|
||||
@@ -119,7 +123,6 @@ class Merger {
|
||||
|
||||
const migrate = migrations[version][type];
|
||||
if (migrate) {
|
||||
console.log(migrate, version, type);
|
||||
return migrate(deserialized);
|
||||
}
|
||||
return deserialized;
|
||||
|
||||
@@ -5,6 +5,8 @@ export function getContentFromData(type, data) {
|
||||
case "tiptap":
|
||||
return new Tiptap(data);
|
||||
default:
|
||||
return null;
|
||||
throw new Error(
|
||||
`Unknown content type: "${type}". Please report this error at support@streetwriters.co.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user