modified data.name to just name

This commit is contained in:
Martina 2021-08-28 17:29:17 -07:00
parent ea71647352
commit b45be08ffb
22 changed files with 67 additions and 65 deletions

View File

@ -127,6 +127,7 @@ export const uploadFiles = async ({ context, files, slate, keys, numFailed = 0 }
context._handleRegisterLoadingFinished({ keys });
};
//NOTE(migration): check that upload works still and file.name
export const upload = async ({ file, context, bucketName }) => {
const currentFileKey = fileKey(file);
let formData = new FormData();

View File

@ -20,16 +20,16 @@ export const getKey = (text) => {
};
export const getPresentationSlateName = (slate) => {
if (!isEmpty(slate.data.name)) {
return slate.data.name;
if (!isEmpty(slate.name)) {
return slate.name;
}
return slate.slatename;
};
export const getPresentationName = (user) => {
if (!isEmpty(user.data.name)) {
return user.data.name;
if (!isEmpty(user.name)) {
return user.name;
}
return user.username;

View File

@ -157,7 +157,7 @@ export class ApplicationUserControlsPopup extends React.Component {
render() {
if (this.props.popup !== "profile") return null;
const username = this.props.viewer.data.name || `@${this.props.viewer.username}`;
const username = this.props.viewer.name || `@${this.props.viewer.username}`;
const objectsLength = this.props.viewer.library.length;
const { stats } = this.props.viewer;

View File

@ -281,7 +281,7 @@ export const FileTypeDefaultPreview = (props) => {
class CarouselSidebar extends React.Component {
state = {
name: this.props.file.data.name || this.props.file.filename || "",
name: this.props.file.name || this.props.file.filename || "",
body: this.props.file.data.body || "",
source: this.props.file.data.source || "",
author: this.props.file.data.author || "",
@ -601,7 +601,7 @@ class CarouselSidebar extends React.Component {
</div>
);
} else {
const hasName = !Strings.isEmpty(file.data.name || file.filename);
const hasName = !Strings.isEmpty(file.name || file.filename);
const hasBody = !Strings.isEmpty(file.data.body);
const hasSource = !Strings.isEmpty(file.data.source);
const hasAuthor = !Strings.isEmpty(file.data.author);
@ -610,7 +610,7 @@ class CarouselSidebar extends React.Component {
elements.push(
<div key="sidebar-media-info-name" css={STYLES_SIDEBAR_SECTION}>
<div css={STYLES_HEADING}>
<ProcessedText dark text={file.data.name || file.filename} />
<ProcessedText dark text={file.name || file.filename} />
</div>
</div>
);

View File

@ -112,7 +112,7 @@ export default function CollectionPreview({ collection, viewer, owner, onAction
const { follow, followCount, isFollowed } = useFollowHandler({ collection, viewer });
const { fileCount, isPublic } = collection;
const title = collection?.data?.name || collection.slatename;
const title = collection.name || collection.slatename;
const isOwner = viewer?.id === collection.ownerId;
const preview = React.useMemo(() => getObjectToPreview(collection.objects), [collection.objects]);

View File

@ -658,7 +658,7 @@ export default class DataView extends React.Component {
_handleDragToDesktop = (e, object) => {
const url = Strings.getURLfromCID(object.cid);
const title = object.filename || object.data.name;
const title = object.filename || object.name;
const type = object.data.type;
console.log(e.dataTransfer, e.dataTransfer.setData);
e.dataTransfer.setData("DownloadURL", `${type}:${title}:${url}`);
@ -986,7 +986,7 @@ export default class DataView extends React.Component {
<div css={STYLES_ICON_BOX_HOVER} style={{ paddingLeft: 0, paddingRight: 18 }}>
<FileTypeIcon file={each} height="24px" />
</div>
<div css={STYLES_LINK}>{each.data.name || each.filename}</div>
<div css={STYLES_LINK}>{each.name || each.filename}</div>
</div>
</Link>
</FilePreviewBubble>

View File

@ -106,7 +106,7 @@ export default function ObjectPreviewPrimitive({
const { isLink } = file;
const title = file.data.name || file.filename;
const title = file.name || file.filename;
if (file?.data?.coverImage && !isImage && !isLink) {
return (

View File

@ -88,9 +88,9 @@ const UserEntry = ({ user }) => {
<ProfilePhoto user={user} size={48} />
</div>
<div css={STYLES_TEXT_ROWS}>
{user.data.name ? (
{user.name ? (
<React.Fragment>
<div css={STYLES_TITLE}>{user.data.name}</div>
<div css={STYLES_TITLE}>{user.name}</div>
<div css={STYLES_SUBTITLE}>@{user.username}</div>
</React.Fragment>
) : (
@ -120,7 +120,7 @@ const UserPreview = ({ user }) => {
<ProfilePhoto user={user} size={182} />
</div>
{user.data.name ? <div css={STYLES_PREVIEW_TEXT}>{user.data.name}</div> : null}
{user.name ? <div css={STYLES_PREVIEW_TEXT}>{user.name}</div> : null}
<div css={STYLES_PREVIEW_TEXT}>@{user.username}</div>
{user.data.slates ? (
<div css={STYLES_PREVIEW_TEXT}>
@ -176,8 +176,8 @@ const SlateEntry = ({ slate, user }) => {
<SVG.Slate height="24px" />
</div>
<div css={STYLES_TEXT_ROWS}>
<div css={STYLES_TITLE}>{slate.data.name || slate.slatename}</div>
{user ? <div css={STYLES_SUBTITLE}>{user.data.name || `@${user.username}`}</div> : null}
<div css={STYLES_TITLE}>{slate.name || slate.slatename}</div>
{user ? <div css={STYLES_SUBTITLE}>{user.name || `@${user.username}`}</div> : null}
</div>
</div>
</div>
@ -236,7 +236,7 @@ const SlatePreview = ({ slate, user }) => {
)}
</div>
{user ? (
<div css={STYLES_PREVIEW_TEXT}>Created by: {user.data.name || `@${user.username}`}</div>
<div css={STYLES_PREVIEW_TEXT}>Created by: {user.name || `@${user.username}`}</div>
) : null}
{slate.objects && (
<div css={STYLES_PREVIEW_TEXT}>
@ -255,7 +255,7 @@ const FileEntry = ({ file }) => {
<FileTypeIcon file={file} height="24px" />
</div>
<div css={STYLES_TEXT_ROWS}>
<div css={STYLES_TITLE}>{file.data.name || file.filename}</div>
<div css={STYLES_TITLE}>{file.name || file.filename}</div>
<div css={STYLES_SUBTITLE} style={{ textTransform: "uppercase" }}>
{Strings.getFileExtension(file.filename)}
</div>
@ -271,11 +271,9 @@ const FilePreview = ({ file, slate, user, viewerId }) => {
<div css={STYLES_PREVIEW_IMAGE}>
<SlateMediaObjectPreview file={file} previewPanel />
</div>
{user ? (
<div css={STYLES_PREVIEW_TEXT}>Owner: {user.data.name || `@${user.username}`}</div>
) : null}
{user ? <div css={STYLES_PREVIEW_TEXT}>Owner: {user.name || `@${user.username}`}</div> : null}
{slate ? (
<div css={STYLES_PREVIEW_TEXT}>Collection: {slate.data.name || slate.slatename}</div>
<div css={STYLES_PREVIEW_TEXT}>Collection: {slate.name || slate.slatename}</div>
) : user?.id === viewerId ? (
<div css={STYLES_PREVIEW_TEXT}>In your files</div>
) : null}

View File

@ -28,7 +28,7 @@ const formatDataSafely = ({ collection, user }) => {
const rootUrl = window?.location?.origin;
return {
id: collection.id,
title: collection?.data?.name || collection?.slatename,
title: collection?.name || collection?.slatename,
link: `${rootUrl}/${user.username}/${collection.slatename}`,
};
};
@ -38,10 +38,10 @@ export const CollectionSharingModal = () => {
const { open, user, collection, view, preview } = state;
const { closeModal, changeView, handleModalVisibility } = handlers;
const { id, title, link } = React.useMemo(
() => formatDataSafely({ collection, user }),
[user, collection]
);
const { id, title, link } = React.useMemo(() => formatDataSafely({ collection, user }), [
user,
collection,
]);
useEventListener("collection-sharing-modal", handleModalVisibility, []);

View File

@ -167,7 +167,7 @@ export default class SlateMediaObject extends React.Component {
if (Validations.isFontFile(file.filename)) {
return (
<FontFrame
name={file.data.name || file.filename}
name={file.name || file.filename}
cid={file.cid}
fallback={element}
onClick={(e) => {

View File

@ -182,7 +182,7 @@ export default class SlateMediaObjectPreview extends React.Component {
);
}
let name = (file.data?.name || file.filename || "").substring(0, this.charCap);
let name = (file.name || file.filename || "").substring(0, this.charCap);
let extension = Strings.getFileExtension(file.filename);
if (extension && extension.length) {
extension = extension.toUpperCase();

View File

@ -306,7 +306,7 @@ export class SlatePreviewBlock extends React.Component {
<span css={STYLES_MOBILE_HIDDEN}>
<div css={STYLES_TITLE_LINE}>
<div css={STYLES_TITLE} style={{ width: "85%" }}>
{this.props.slate.data.name}
{this.props.slate.name}
{this.props.isOwner && !this.props.slate.isPublic && (
<span style={{ marginLeft: 8 }}>
<SVG.SecurityLock height="20px" />
@ -365,7 +365,7 @@ export class SlatePreviewBlock extends React.Component {
</span>
<span css={STYLES_MOBILE_ONLY}>
<div css={STYLES_TITLE_LINE}>
<div css={STYLES_TITLE}>{this.props.slate.data.name}</div>
<div css={STYLES_TITLE}>{this.props.slate.name}</div>
{this.props.isOwner && !this.props.slate.isPublic && (
<div style={{ color: Constants.system.grayLight2, margin: `2px 0 0 0` }}>
<SVG.SecurityLock height="20px" />

View File

@ -147,7 +147,7 @@ export default class SidebarAddFileToBucket extends React.Component {
<System.P1>
Click below or drop a file anywhere on the page to upload a file
{this.props.data?.slatename || this.props.data?.data.name ? (
{this.props.data?.slatename || this.props.data?.name ? (
<span>
{" "}
to <strong>{Strings.getPresentationSlateName(this.props.data)}</strong>

View File

@ -25,9 +25,9 @@ const STYLES_TEXT = css`
font-size: ${Constants.typescale.lvl0};
`;
export default class SidebarCreateSlate extends React.Component {
export default class SidebarHelp extends React.Component {
state = {
name: this.props.viewer?.data?.name ? this.props.viewer.data.name : "",
name: this.props.viewer?.name || "",
email: "",
twitter: "",
message: "",

View File

@ -50,7 +50,7 @@ export default class SidebarSingleSlateSettings extends React.Component {
slatename: this.props.data.slatename,
isPublic: this.props.data.isPublic,
body: this.props.data.data.body,
name: this.props.data.data.name,
name: this.props.data.name,
modalShow: false,
};
@ -58,7 +58,7 @@ export default class SidebarSingleSlateSettings extends React.Component {
let slates = this.props.viewer.slates;
for (let slate of slates) {
if (slate.id === this.props.data.id) {
slate.data.name = this.state.name;
slate.name = this.state.name;
slate.isPublic = this.state.isPublic;
slate.data.body = this.state.body;

View File

@ -41,7 +41,7 @@ export const upload = ({ user, slate, files: targetFiles }) => {
let message;
if (slate) {
const objectURL = `<https://slate.host/${user.username}/${slate.slatename}?cid=${files[0].cid}|${files[0].filename}>`;
const slateURL = `<https://slate.host/${user.username}/${slate.slatename}|${slate.data.name}>`;
const slateURL = `<https://slate.host/${user.username}/${slate.slatename}|${slate.name}>`;
message = `*${userURL}* uploaded ${objectURL}${extra} to ${slateURL}`;
} else {
const objectURL = `<https://slate.host/${user.username}?cid=${files[0].cid}|${files[0].filename}>`;
@ -88,7 +88,7 @@ export const saveCopy = ({ slate, user, files: targetFiles }) => {
let message;
if (slate) {
const objectURL = `<https://slate.host/${user.username}/${slate.slatename}?cid=${files[0].cid}|${files[0].filename}>`;
const slateURL = `<https://slate.host/${user.username}/${slate.slatename}|${slate.data.name}>`;
const slateURL = `<https://slate.host/${user.username}/${slate.slatename}|${slate.name}>`;
message = `*${userURL}* saved ${objectURL}${extra} to ${slateURL}`;
} else {
const objectURL = `<https://slate.host/${user.username}?cid=${files[0].cid}|${files[0].filename}>`;
@ -105,7 +105,7 @@ export const createSlate = ({ user, slate }) => {
if (!slate.isPublic) return;
try {
const userURL = getUserURL(user);
const slateURL = `<https://slate.host/${user.username}/${slate.slatename}|${slate.data.name}>`;
const slateURL = `<https://slate.host/${user.username}/${slate.slatename}|${slate.name}>`;
const message = `*${userURL}* created a collection ${slateURL}`;
Social.sendSlackMessage(message);
@ -142,7 +142,7 @@ export const subscribeSlate = ({ user, targetSlate }) => {
if (!targetSlate.isPublic) return;
try {
const userURL = getUserURL(user);
const targetSlateURL = `<https://slate.host/$/${targetSlate.id}|${targetSlate.data.name}>`;
const targetSlateURL = `<https://slate.host/$/${targetSlate.id}|${targetSlate.name}>`;
const message = `*${userURL}* subscribed to ${targetSlateURL}`;

View File

@ -11,8 +11,8 @@ export const sanitizeUser = (entity) => {
username: entity.username,
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,
data: {
name: entity.data?.name,
photo: entity.data?.photo,
body: entity.data?.body,
},
@ -25,13 +25,13 @@ export const sanitizeSlate = (entity) => {
return {
id: entity.id,
slatename: entity.slatename,
name: entity.name,
ownerId: entity.ownerId,
isPublic: entity.isPublic,
objects: entity.objects,
owner: entity.owner,
user: entity.user, //NOTE(martina): this is not in the database. It is added after
data: {
name: entity.data?.name,
body: entity.data?.body,
preview: entity.data?.preview,
},
@ -47,10 +47,10 @@ export const sanitizeFile = (entity) => {
ownerId: entity.ownerId,
isPublic: entity.isPublic,
filename: entity.filename,
name: entity.name,
createdAt: entity.createdAt,
data: {
type: entity.data?.type,
name: entity.data?.name,
size: entity.data?.size,
body: entity.data?.body,
source: entity.data?.source,
@ -75,6 +75,7 @@ export const cleanUser = (entity) => {
return {
id: entity.id,
username: entity.username,
name: entity.name,
createdAt: entity.createdAt,
lastActive: entity.lastActive,
salt: entity.salt,
@ -84,7 +85,6 @@ export const cleanUser = (entity) => {
authVersion: entity.authVersion,
data: entity.data,
// data: {
// name: entity.data?.name,
// photo: entity.data?.photo,
// body: entity.data?.body,
// tokens: entity.data?.tokens,
@ -101,11 +101,11 @@ export const cleanSlate = (entity) => {
createdAt: entity.createdAt,
updatedAt: entity.updatedAt,
slatename: entity.slatename,
name: entity.name,
isPublic: entity.isPublic,
ownerId: entity.ownerId,
data: entity.data,
// data: {
// name: entity.data?.name,
// body: entity.data?.body,
// preview: entity.data?.preview,
// },
@ -120,12 +120,12 @@ export const cleanFile = (entity) => {
ownerId: entity.ownerId,
isPublic: entity.isPublic,
filename: entity.filename,
name: entity.name,
data: entity.data,
isLink: entity.isLink,
url: entity.url,
// data: {
// type: entity.data?.type,
// name: entity.data?.name,
// size: entity.data?.size,
// body: entity.data?.body,
// source: entity.data?.source,
@ -162,6 +162,7 @@ export const getUpdatedUser = (oldUser, updates) => {
export const slateProperties = [
"slates.id",
"slates.slatename",
"slates.name",
"slates.data",
"slates.ownerId",
"slates.isPublic",
@ -172,6 +173,7 @@ export const slateProperties = [
export const userProperties = [
"users.id",
"users.username",
"users.name",
"users.data",
"users.slateCount",
"users.followerCount",
@ -183,6 +185,7 @@ export const fileProperties = [
"files.cid",
"files.isPublic",
"files.filename",
"files.name",
"files.data",
"files.createdAt",
"files.downloadCount",

View File

@ -58,8 +58,8 @@ export default class ProfilePage extends React.Component {
render() {
const title = this.props.creator
? this.props.creator.data.name
? `${this.props.creator.data.name} on Slate`
? this.props.creator.name
? `${this.props.creator.name} on Slate`
: `@${this.props.creator.username} on Slate`
: "404";
const url = `https://slate.host/${title}`;

View File

@ -125,7 +125,7 @@ function UserEntry({ user, button, onClick, message, checkStatus }) {
{isOnline ? <div css={STYLES_STATUS_INDICATOR} /> : null}
</div>
<span css={STYLES_NAME}>
{user.data.name || `@${user.username}`}
{user.name || `@${user.username}`}
{message ? <span css={STYLES_MESSAGE}>{message}</span> : null}
</span>
</div>

View File

@ -48,7 +48,7 @@ export default class SceneEditAccount extends React.Component {
confirm: "",
body: this.props.viewer.data.body,
photo: this.props.viewer.data.photo,
name: this.props.viewer.data.name,
name: this.props.viewer.name,
deleting: false,
allow_filecoin_directory_listing: this.props.viewer.data.settings
?.allow_filecoin_directory_listing,
@ -108,17 +108,17 @@ export default class SceneEditAccount extends React.Component {
return;
}
let data = { ...this.props.viewer.data, body: this.state.body, name: this.state.name };
this.props.onAction({ type: "UPDATE_VIEWER", viewer: { username: this.state.username, data } });
this.props.onAction({
type: "UPDATE_VIEWER",
viewer: { username: this.state.username, name: this.state.name, body: this.state.body },
});
this.setState({ savingNameBio: true });
let response = await Actions.updateViewer({
username: this.state.username,
data: {
photo: this.state.photo,
body: this.state.body,
name: this.state.name,
},
photo: this.state.photo,
body: this.state.body,
name: this.state.name,
});
Events.hasError(response);

View File

@ -151,13 +151,13 @@ export default class SceneProfile extends React.Component {
</WebsitePrototypeWrapper>
);
}
let name = user.data.name || `@${user.username}`;
let name = user.name || `@${user.username}`;
let description, title, file, image;
if (this.props.page.params?.cid) {
file = user.library.find((file) => file.cid === this.props.page.params.cid);
}
if (file) {
title = `${file.data.name || file.filename}`;
title = `${file.name || file.filename}`;
description = file.data.body ? file.data.body : `View ${title}, a file from ${name} on Slate`;
image = Utilities.getImageUrlIfExists(file, Constants.linkPreviewSizeLimit);
} else {
@ -167,8 +167,8 @@ export default class SceneProfile extends React.Component {
} else {
description = `View collections and content from ${name} on Slate`;
}
if (user.data.name) {
title = `${user.data.name} (@${user.username}) • Slate`;
if (user.name) {
title = `${user.name} (@${user.username}) • Slate`;
} else {
title = `${user.username} • Slate`;
}

View File

@ -212,12 +212,12 @@ export default class SceneSlate extends React.Component {
);
} else {
let title, description, file, image;
let name = slate.data.name;
let name = slate.name;
if (this.props.page.params?.cid) {
file = slate.objects.find((file) => file.cid === this.props.page.params.cid);
}
if (file) {
title = `${file.data.name || file.filename}`;
title = `${file.name || file.filename}`;
description = file.data.body
? file.data.body
: `View ${title}, a file in the collection ${name} on Slate`;
@ -393,7 +393,7 @@ class SlatePage extends React.Component {
Events.dispatchCustomEvent({ name: "slate-global-open-cta", detail: {} });
return;
}
const slateName = this.props.data.data.name;
const slateName = this.props.data.slatename;
const slateFiles = this.props.data.objects;
UserBehaviors.compressAndDownloadFiles({
files: slateFiles,