removed remaining mentions of user.data, slate.data, file.data

This commit is contained in:
Martina 2021-09-01 15:26:25 -07:00
parent c53f7a42af
commit e4e4f67293
11 changed files with 30 additions and 48 deletions

View File

@ -41,12 +41,10 @@ export const useForm = ({
});
const _hasError = (obj) => Object.keys(obj).some((name) => obj[name]);
const _mergeEventHandlers =
(events = []) =>
(e) =>
events.forEach((event) => {
if (event) event(e);
});
const _mergeEventHandlers = (events = []) => (e) =>
events.forEach((event) => {
if (event) event(e);
});
/** ---------- NOTE(amine): Input Handlers ---------- */
const handleFieldChange = (e) =>
@ -166,12 +164,10 @@ export const useField = ({
touched: undefined,
});
const _mergeEventHandlers =
(events = []) =>
(e) =>
events.forEach((event) => {
if (event) event(e);
});
const _mergeEventHandlers = (events = []) => (e) =>
events.forEach((event) => {
if (event) event(e);
});
const setFieldValue = (value) =>
setState((prev) => ({
@ -338,7 +334,6 @@ export const useFollowProfileHandler = ({ user, viewer, onAction }) => {
: viewer.following.concat([
{
id: user.id,
data: user.data,
followerCount: user.followerCount + 1,
slateCount: user.slateCount,
username: user.username,

View File

@ -44,8 +44,7 @@ const STYLES_MOBILE_ALIGN = (theme) => css`
export default function ProfileInfo({ owner, viewer, time, action, onAction }) {
const { isFollowing, handleFollow } = useFollowProfileHandler({ viewer, user: owner, onAction });
const { username, data = {} } = owner;
const { photo } = data;
const { username, photo } = owner;
const formattedDate = Utilities.getTimeDifferenceFromNow(time);
const mobileFormattedDate = Utilities.getTimeDifferenceFromNow(time, {

View File

@ -233,7 +233,7 @@ function Metrics({ fileCount, owner, isOwner, onAction }) {
>
<img
css={STYLES_PROFILE_IMAGE}
src={owner?.data?.photo}
src={owner.photo}
alt={`${owner.username} profile`}
onError={(e) => (e.target.src = Constants.profileDefaultPicture)}
/>

View File

@ -69,8 +69,8 @@ export default function ProfilePhoto({ size, style, ...props }) {
return (
<>
{props.user.data.photo ? (
<UploadedAvatar url={props.user.data.photo} style={style} avatarCss={STYLES_SIZE} />
{props.user.photo ? (
<UploadedAvatar url={props.user.photo} style={style} avatarCss={STYLES_SIZE} />
) : (
<BoringAvatar userId={props.user.id} style={style} avatarCss={STYLES_SIZE} />
)}

View File

@ -74,10 +74,8 @@ export default class SidebarSingleSlateSettings extends React.Component {
const response = await Actions.updateSlate({
id: this.props.data.id,
isPublic: this.state.isPublic,
data: {
name: this.state.name,
body: this.state.body,
},
name: this.state.name,
body: this.state.body,
});
if (Events.hasError(response)) {

View File

@ -68,7 +68,6 @@ export const hydratePartial = async (
...update,
username: user.username,
email: user.email,
data: user.data,
library: user.library,
};
} else if (library) {
@ -207,16 +206,7 @@ export const getById = async ({ id }) => {
// const tags = Utilities.getUserTags({ library: user.library });
let viewer = {
id: user.id,
username: user.username,
email: user.email || null,
data: user.data,
library: user.library,
settingsDealsAutoApprove: user.settingsDealsAutoApprove,
allowAutomaticDataStorage: user.allowAutomaticDataStorage,
allowEncryptedDataStorage: user.allowEncryptedDataStorage,
onboarding: user.onboarding || {},
// status: user.data.status || {},
...user,
stats: {
bytes,
maximumBytes: Constants.TEXTILE_ACCOUNT_BYTE_LIMIT,

View File

@ -157,17 +157,21 @@ export const cleanFile = (entity) => {
export const getUpdatedSlate = (oldSlate, updates) => {
let updatedSlate = cleanSlate(updates);
return { ...oldSlate, ...updatedSlate, data: { ...oldSlate.data, ...updatedSlate.data } };
return { ...oldSlate, ...updatedSlate };
};
export const getUpdatedFile = (oldFile, updates) => {
let updatedFile = cleanFile(updates);
return { ...oldFile, ...updatedFile, data: { ...oldFile.data, ...updatedFile.data } };
let mergedFile = { ...oldFile, ...updatedFile };
if (updatedFile.data) {
let data = { ...oldFile.data, ...updatedFile.data };
mergedFile.data = data;
}
};
export const getUpdatedUser = (oldUser, updates) => {
let updatedUser = cleanUser(updates);
return { ...oldUser, ...updatedUser, data: { ...oldUser.data, ...updatedUser.data } };
return { ...oldUser, ...updatedUser };
};
//NOTE(martina): list of the properties of the tables that should be returned by db queries
@ -176,7 +180,6 @@ export const slateProperties = [
"slates.slatename",
"slates.name",
"slates.body",
"slates.data",
"slates.ownerId",
"slates.isPublic",
"slates.subscriberCount",
@ -188,7 +191,6 @@ export const userProperties = [
"users.username",
"users.name",
"users.body",
"users.data",
"users.slateCount",
"users.followerCount",
];

View File

@ -229,7 +229,7 @@ export default class SceneSlate extends React.Component {
description = `View the collection ${name} on Slate`;
}
title = `${name} • Slate`;
image = slate.data.preview;
image = slate.preview;
const objects = slate.objects;
if (!image && objects) {
for (let i = 0; i < objects.length; i++) {
@ -339,7 +339,7 @@ class SlatePage extends React.Component {
let slateId = this.props.data.id;
for (let slate of slates) {
if (slate.id === slateId) {
slate.data.preview = preview;
slate.preview = preview;
break;
}
}
@ -402,10 +402,8 @@ class SlatePage extends React.Component {
};
render() {
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;
const { user, objects, body, isPublic, ownerId } = this.props.data;
const isOwner = this.props.viewer ? ownerId === this.props.viewer.id : false;
let actions = isOwner ? (
<span>

View File

@ -244,7 +244,7 @@ const deleteUserData = async () => {
table.dropColumn("data");
});
await DB.schema.table("files", function (table) {
table.dropColumn("data");
table.dropColumn("oldData");
});
};

View File

@ -38,7 +38,7 @@ const run = async () => {
count = count + 1;
let userBytes = 0;
user.data.library.forEach((each) => {
user.library.forEach((each) => {
userBytes = each.size + userBytes;
bytes = each.size + bytes;
});

View File

@ -194,8 +194,8 @@ const run = async () => {
user: {
id: user.id,
username: user.username,
photo: user.data.photo,
name: user.data.name,
photo: user.photo,
name: user.name,
},
});
});