From c9ee940a94a5e1e485ac9c10dcad130f3ccbf56b Mon Sep 17 00:00:00 2001 From: Martina Date: Tue, 20 Apr 2021 19:11:38 -0700 Subject: [PATCH] fixed undefined bug with ends with any --- common/utilities.js | 9 ++++++- components/core/SlateMediaObjectPreview.js | 4 +++- pages/api/data/archive.js | 2 +- scripts/files-migration.js | 28 ++++++++++------------ 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/common/utilities.js b/common/utilities.js index b33d0ac5..9ad878e3 100644 --- a/common/utilities.js +++ b/common/utilities.js @@ -33,4 +33,11 @@ export const generateNumberByStep = ({ min, max, step = 1 }) => { return numbers[randomIndex]; }; -export const endsWithAny = (options, string) => options.some((option) => string.endsWith(option)); +export const endsWithAny = (options, string) => + options.some((option) => { + if (string) { + return string.endsWith(option); + } else { + return false; + } + }); diff --git a/components/core/SlateMediaObjectPreview.js b/components/core/SlateMediaObjectPreview.js index cc6aad9c..0d2a171d 100644 --- a/components/core/SlateMediaObjectPreview.js +++ b/components/core/SlateMediaObjectPreview.js @@ -198,7 +198,9 @@ export default class SlateMediaObjectPreview extends React.Component { style={{ color: Constants.system.textGray }} /> ); - + if (!file.filename) { + console.log(file); + } if (endsWithAny([".ttf", ".otf", ".woff", ".woff2"], file.filename)) { return (
{ let key = bucketRoot.key; let encryptedBucketName = null; - if (user.data.settings.allow_encrypted_data_storage || req.body.data.forceEncryption) { + if (user.data.settings?.allow_encrypted_data_storage || req.body.data.forceEncryption) { encryptedBucketName = req.body.data.forceEncryption ? `encrypted-deal-${uuid()}` : `encrypted-data-${uuid()}`; diff --git a/scripts/files-migration.js b/scripts/files-migration.js index ec7db564..a711cef8 100644 --- a/scripts/files-migration.js +++ b/scripts/files-migration.js @@ -44,9 +44,9 @@ const printUsersTable = async () => { } } } - console.log(Object.keys(dataParams)); - console.log(Object.keys(fileParams)); - console.log(Object.keys(coverParams)); + console.log({ dataParams: Object.keys(dataParams) }); + console.log({ fileParams: Object.keys(fileParams) }); + console.log({ coverParams: Object.keys(coverParams) }); }; const printSlatesTable = async () => { @@ -78,22 +78,22 @@ const printSlatesTable = async () => { } } } - console.log(Object.keys(dataParams)); - console.log(Object.keys(fileParams)); - console.log(Object.keys(coverParams)); + console.log({ dataParams: Object.keys(dataParams) }); + console.log({ fileParams: Object.keys(fileParams) }); + console.log({ coverParams: Object.keys(coverParams) }); }; // MARK: - add/modify tables const addTables = async () => { await DB.schema.table("deals", function (table) { - table.renameColumn("owner_user_id", "ownerId"); //replaced + table.renameColumn("owner_user_id", "ownerId"); table.renameColumn("created_at", "createdAt"); - table.renameColumn("updated_at", "updatedAt"); //replaced + table.renameColumn("updated_at", "updatedAt"); }); await DB.schema.table("keys", function (table) { - table.renameColumn("owner_id", "ownerId"); //replaced + table.renameColumn("owner_id", "ownerId"); table.renameColumn("created_at", "createdAt"); }); @@ -170,10 +170,6 @@ const addTables = async () => { // MARK: - populate new tables -//strip out the "data-" in the id so it can be a uuid -//if there's a file with that id already existing, this is probably a save copy instance. So give this one a new id -//when matching slate fiels to files, if you can't find it by id, match it by cid and ownerId. should only be one match. - const migrateUsersTable = async (testing = false) => { const users = await DB.select("*").from("users"); let count = 0; @@ -542,11 +538,11 @@ const runScript = async () => { // await wipeNewTables(); //NOTE(martina): before starting, make sure you have all the parameters accounted for - // await printUsersTable() - // await printSlatesTable() + await printUsersTable(); + await printSlatesTable(); //NOTE(martina): add tables - await addTables(); + // await addTables(); //NOTE(martina): put data into new tables let testing = false;