converting data.body to body

This commit is contained in:
Martina 2021-08-28 18:36:48 -07:00
parent b45be08ffb
commit cabcdc31ec
15 changed files with 44 additions and 47 deletions

View File

@ -282,7 +282,7 @@ export const FileTypeDefaultPreview = (props) => {
class CarouselSidebar extends React.Component {
state = {
name: this.props.file.name || this.props.file.filename || "",
body: this.props.file.data.body || "",
body: this.props.file.body || "",
source: this.props.file.data.source || "",
author: this.props.file.data.author || "",
tags: this.props.file.data.tags || [],
@ -366,13 +366,10 @@ class CarouselSidebar extends React.Component {
this.props.onAction({ type: "UPDATE_VIEWER", viewer: { tags: this.state.suggestions } });
const response = await Actions.updateFile({
id: this.props.file.id,
data: {
name: this.state.name,
body: this.state.body,
source: this.state.source,
author: this.state.author,
tags: this.state.tags,
},
name: this.state.name,
body: this.state.body,
source: this.state.source,
author: this.state.author,
});
Events.hasError(response);
this.setState({ showSavedMessage: true });
@ -602,7 +599,7 @@ class CarouselSidebar extends React.Component {
);
} else {
const hasName = !Strings.isEmpty(file.name || file.filename);
const hasBody = !Strings.isEmpty(file.data.body);
const hasBody = !Strings.isEmpty(file.body);
const hasSource = !Strings.isEmpty(file.data.source);
const hasAuthor = !Strings.isEmpty(file.data.author);
@ -635,7 +632,7 @@ class CarouselSidebar extends React.Component {
elements.push(
<div key="sidebar-media-info-body" css={STYLES_SIDEBAR_SECTION}>
<div css={STYLES_BODY}>
<ProcessedText dark text={file.data.body} />
<ProcessedText dark text={file.body} />
</div>
</div>
);

View File

@ -94,7 +94,7 @@ export default function CollectionPreview({ collection, viewer, owner, onAction
const showControls = () => setShowControls(true);
const hideControls = () => setShowControls(false);
const description = collection?.data?.body;
const description = collection?.body;
const media = useMediaQuery();
const { isDescriptionVisible, showDescription, hideDescription } = useShowDescription({
disabled: !description || media.mobile,

View File

@ -20,7 +20,7 @@ const STYLES_ASSET = (theme) => css`
const STYLES_BODY = css`
width: 100%;
// 687px to ensure we have maximum 70ch per line
/* 687px to ensure we have maximum 70ch per line */
max-width: 687px;
margin: 0 auto;
& > *:first-child {

View File

@ -89,7 +89,7 @@ export default function ObjectPreviewPrimitive({
// const showControls = () => setShowControls(true);
// const hideControls = () => setShowControls(false);
const description = file?.data?.body;
const description = file?.body;
const media = useMediaQuery();
const { isDescriptionVisible, showDescription, hideDescription } = useShowDescription({
disabled: !description || media.mobile,

View File

@ -325,9 +325,9 @@ export default class Profile extends React.Component {
)}
</div>
)}
{user.data.body ? (
{user.body ? (
<div css={STYLES_DESCRIPTION}>
<ProcessedText text={user.data.body} />
<ProcessedText text={user.body} />
</div>
) : null}
<div css={STYLES_STATS}>

View File

@ -66,9 +66,9 @@ export default function ProfilePreviewBlock({ onAction, viewer, profile }) {
<Typography.P2
color="gray"
nbrOflines={1}
style={{ marginTop: 8, textIndent: 8, opacity: profile?.data?.body ? 1 : 0 }}
style={{ marginTop: 8, textIndent: 8, opacity: profile?.body ? 1 : 0 }}
>
{profile?.data?.body || "No Description"}
{profile?.body || "No Description"}
</Typography.P2>
{!isOwner &&

View File

@ -333,9 +333,7 @@ export class SlatePreviewBlock extends React.Component {
</div>
)}
</div>
<div css={STYLES_BODY}>
{this.props.slate.data.body ? this.props.slate.data.body : null}
</div>
<div css={STYLES_BODY}>{this.props.slate.body}</div>
{objects.length === 0 ? (
<div
css={STYLES_PLACEHOLDER}
@ -372,9 +370,9 @@ export class SlatePreviewBlock extends React.Component {
</div>
)}
</div>
{this.props.slate.data.body ? (
{this.props.slate.body ? (
<div css={STYLES_BODY} style={{ marginBottom: 16 }}>
{this.props.slate.data.body}
{this.props.slate.body}
</div>
) : (
<div style={{ height: 8 }} />

View File

@ -49,7 +49,7 @@ export default class SidebarSingleSlateSettings extends React.Component {
state = {
slatename: this.props.data.slatename,
isPublic: this.props.data.isPublic,
body: this.props.data.data.body,
body: this.props.data.body,
name: this.props.data.name,
modalShow: false,
};
@ -60,7 +60,7 @@ export default class SidebarSingleSlateSettings extends React.Component {
if (slate.id === this.props.data.id) {
slate.name = this.state.name;
slate.isPublic = this.state.isPublic;
slate.data.body = this.state.body;
slate.body = this.state.body;
this.props.onAction({
type: "UPDATE_VIEWER",

View File

@ -12,9 +12,9 @@ export const sanitizeUser = (entity) => {
slates: entity.slates, //NOTE(martina): this is not in the database. It is added after
library: entity.library, //NOTE(martina): this is not in the database. It is added after
name: entity.name,
body: entity.body,
data: {
photo: entity.data?.photo,
body: entity.data?.body,
},
followerCount: entity.followerCount,
slateCount: entity.slateCount,
@ -31,8 +31,8 @@ export const sanitizeSlate = (entity) => {
objects: entity.objects,
owner: entity.owner,
user: entity.user, //NOTE(martina): this is not in the database. It is added after
body: entity.body,
data: {
body: entity.data?.body,
preview: entity.data?.preview,
},
fileCount: entity.fileCount,
@ -49,10 +49,10 @@ export const sanitizeFile = (entity) => {
filename: entity.filename,
name: entity.name,
createdAt: entity.createdAt,
body: entity.body,
data: {
type: entity.data?.type,
size: entity.data?.size,
body: entity.data?.body,
source: entity.data?.source,
author: entity.data?.author,
blurhash: entity.data?.blurhash,
@ -84,9 +84,9 @@ export const cleanUser = (entity) => {
twitterId: entity.twitterId,
authVersion: entity.authVersion,
data: entity.data,
body: entity.body,
// data: {
// photo: entity.data?.photo,
// body: entity.data?.body,
// tokens: entity.data?.tokens,
// settings: entity.data?.settings,
// onboarding: entity.data?.onboarding,
@ -105,8 +105,8 @@ export const cleanSlate = (entity) => {
isPublic: entity.isPublic,
ownerId: entity.ownerId,
data: entity.data,
body: entity.body,
// data: {
// body: entity.data?.body,
// preview: entity.data?.preview,
// },
};
@ -124,10 +124,10 @@ export const cleanFile = (entity) => {
data: entity.data,
isLink: entity.isLink,
url: entity.url,
body: entity.body,
// data: {
// type: entity.data?.type,
// size: entity.data?.size,
// body: entity.data?.body,
// source: entity.data?.source,
// author: entity.data?.author,
// blurhash: entity.data?.blurhash,
@ -163,6 +163,7 @@ export const slateProperties = [
"slates.id",
"slates.slatename",
"slates.name",
"slates.body",
"slates.data",
"slates.ownerId",
"slates.isPublic",
@ -174,6 +175,7 @@ export const userProperties = [
"users.id",
"users.username",
"users.name",
"users.body",
"users.data",
"users.slateCount",
"users.followerCount",
@ -186,6 +188,7 @@ export const fileProperties = [
"files.isPublic",
"files.filename",
"files.name",
"files.body",
"files.data",
"files.createdAt",
"files.downloadCount",

View File

@ -63,7 +63,7 @@ export default class ProfilePage extends React.Component {
: `@${this.props.creator.username} on Slate`
: "404";
const url = `https://slate.host/${title}`;
const description = this.props.creator.data.body;
const description = this.props.creator.body;
const image = this.props.creator.data.photo;
if (Strings.isEmpty(image)) {
image = DEFAULT_IMAGE;

View File

@ -212,8 +212,8 @@ 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 } = this.props.slate;
let { body, preview } = this.props.slate.data;
let { objects, isPublic, body } = this.props.slate;
let { preview } = this.props.slate.data;
let image;
if (Strings.isEmpty(this.props.cid)) {
image = preview;

View File

@ -46,7 +46,7 @@ export default class SceneEditAccount extends React.Component {
username: this.props.viewer.username,
password: "",
confirm: "",
body: this.props.viewer.data.body,
body: this.props.viewer.body,
photo: this.props.viewer.data.photo,
name: this.props.viewer.name,
deleting: false,

View File

@ -158,12 +158,12 @@ export default class SceneProfile extends React.Component {
}
if (file) {
title = `${file.name || file.filename}`;
description = file.data.body ? file.data.body : `View ${title}, a file from ${name} on Slate`;
description = file.body ? file.body : `View ${title}, a file from ${name} on Slate`;
image = Utilities.getImageUrlIfExists(file, Constants.linkPreviewSizeLimit);
} else {
image = user.data.photo;
if (user.data.body) {
description = `${name}. ${user.data.body}`;
if (user.body) {
description = `${name}. ${user.body}`;
} else {
description = `View collections and content from ${name} on Slate`;
}

View File

@ -218,13 +218,13 @@ export default class SceneSlate extends React.Component {
}
if (file) {
title = `${file.name || file.filename}`;
description = file.data.body
? file.data.body
description = file.body
? file.body
: `View ${title}, a file in the collection ${name} on Slate`;
image = Utilities.getImageUrlIfExists(file, Constants.linkPreviewSizeLimit);
} else {
if (slate.data.body) {
description = `${name}. ${slate.data.body}`;
if (slate.body) {
description = `${name}. ${slate.body}`;
} else {
description = `View the collection ${name} on Slate`;
}
@ -402,8 +402,7 @@ class SlatePage extends React.Component {
};
render() {
const { user, data } = this.props.data;
const { body = "", preview } = data;
const { user, data, body } = this.props.data;
let objects = this.props.data.objects;
const isPublic = this.props.data.isPublic;
const isOwner = this.props.viewer ? this.props.data.ownerId === this.props.viewer.id : false;

View File

@ -266,7 +266,7 @@ runScript();
/*
Users
[
'data.name', -> 'name'
'data.name', -> 'name' MIGRATED
'data.body', -> 'body'
'data.photo', -> 'photo'
'data.status', -> 'hidePrivacyAlert'
@ -281,14 +281,14 @@ Users
Slates
[
'data.body', -> 'name'
'data.name', -> 'body'
'data.name', -> 'name' MIGRATED
'data.body', -> 'body'
]
Files
[
'data.name', -> 'name'
'data.name', -> 'name' MIGRATED
'data.size', -> 'size'
'data.type', -> 'type'
'data.blurhash', -> 'blurhash'