converted slate.data.preview -> slate.preview

This commit is contained in:
Martina 2021-08-31 16:37:57 -07:00
parent 4cbd6cab6f
commit 7081b19f7f
7 changed files with 14 additions and 18 deletions

View File

@ -1,5 +1,4 @@
import "isomorphic-fetch";
import microlink from "@microlink/mql";
import * as Logging from "~/common/logging";
import * as Events from "~/common/custom-events";

View File

@ -43,7 +43,7 @@ export default function ProfilePreviewBlock({ onAction, viewer, profile }) {
<div css={STYLES_CONTAINER}>
<img
css={STYLES_PROFILE_PREVIEW}
src={profile.data.photo}
src={profile.photo}
alt={`${profile.username}`}
onError={(e) => (e.target.src = Constants.profileDefaultPicture)}
/>

View File

@ -247,8 +247,8 @@ export class SlatePreviewBlock extends React.Component {
render() {
const slate = this.props.slate;
let objects;
if (slate.data.preview) {
const cid = Strings.urlToCid(slate.data.preview);
if (slate.preview) {
const cid = Strings.urlToCid(slate.preview);
let preview = slate.objects.find((each) => each.cid === cid);
if (preview) {
objects = [preview];

View File

@ -122,7 +122,7 @@ export default class SidebarSingleSlateSettings extends React.Component {
render() {
const slug = Strings.createSlug(this.state.name);
const url = `/${this.props.viewer.username}/${slug}`;
// let preview = this.props.data.data.preview;
// let preview = this.props.data.preview;
// if (!preview) {
// for (let object of this.props.data.objects) {
// if (

View File

@ -32,9 +32,7 @@ export const sanitizeSlate = (entity) => {
owner: entity.owner,
user: entity.user, //NOTE(martina): this is not in the database. It is added after
body: entity.body,
data: {
preview: entity.data?.preview,
},
preview: entity.preview,
fileCount: entity.fileCount,
subscriberCount: entity.subscriberCount,
};
@ -108,9 +106,7 @@ export const cleanSlate = (entity) => {
ownerId: entity.ownerId,
data: entity.data,
body: entity.body,
// data: {
// preview: entity.data?.preview,
// },
preview: entity.preview,
};
};

View File

@ -212,8 +212,7 @@ export default class SlatePage extends React.Component {
let url = `https://slate.host/${this.props.creator.username}/${this.props.slate.slatename}`;
let headerURL = `https://slate.host/${this.props.creator.username}`;
let { objects, isPublic, body } = this.props.slate;
let { preview } = this.props.slate.data;
let { objects, body, preview } = this.props.slate;
let image;
if (Strings.isEmpty(this.props.cid)) {
image = preview;

View File

@ -131,6 +131,7 @@ const addSlateColumns = async () => {
await DB.schema.table("slates", function (table) {
table.string("body").nullable();
table.string("name").nullable();
table.string("preview").nullable();
});
};
@ -191,6 +192,7 @@ const migrateSlateTable = async () => {
let newSlate = {
name: data.name,
body: data.body,
preview: data.preview,
};
const response = await DB.from("slates").where("id", slate.id).update(newSlate);
}
@ -247,9 +249,9 @@ const deleteUserData = async () => {
};
const runScript = async () => {
// await printUsersTable();
// await printSlatesTable();
// await printFilesTable();
await printUsersTable();
await printSlatesTable();
await printFilesTable();
// await addUserColumns();
// await addSlateColumns();
@ -283,9 +285,9 @@ Slates
[
'data.name', -> 'name' MIGRATED
'data.body', -> 'body' MIGRATED
'data.preview', -> 'preview' MIGRATED
]
Files
[
'data.name', -> 'name' MIGRATED
@ -296,7 +298,7 @@ Files
'data.body', -> 'body' MIGRATED
'data.author', -> 'author' MIGRATED
'data.coverImage', -> 'coverImage' MIGRATED
'data.unity', -> 'data.unity'
'data.unity', -> 'data.unity' MIGRATED
'data.link.name', -> 'linkName'
'data.link.body', -> 'linkBody'
'data.link.author', -> 'linkAuthor'