misc cleanup

This commit is contained in:
Martina 2021-01-20 17:07:40 -08:00
parent e4124f28d1
commit e72b841132
8 changed files with 78 additions and 328 deletions

View File

@ -346,3 +346,9 @@ export const getZipFilePaths = async (data) => {
body: JSON.stringify({ data }),
});
};
export const cleanDatabase = async () => {
return await returnJSON(`api/clean-up/users`, {
...DEFAULT_OPTIONS,
});
};

View File

@ -6,7 +6,6 @@ import * as Actions from "~/common/actions";
import { error } from "~/common/messages";
import { css } from "@emotion/react";
import { LoaderSpinner } from "~/components/system/components/Loaders";
import { PathActions } from "three";
const STYLES_ALERT = `
box-sizing: border-box;

View File

@ -338,45 +338,24 @@ export default class Profile extends React.Component {
enabled
onOutsideRectEvent={(e) => this._handleClick(e, relation.id)}
>
{relation.target_user_id === this.props.viewer?.id ? (
<PopoverNavigation
style={{
top: "40px",
right: "0px",
}}
navigation={[
{
text: "Copy profile URL",
onClick: (e) =>
this._handleCopy(e, `https://slate.host/${relation.user.username}`),
},
]}
/>
) : (
<PopoverNavigation
style={{
top: "40px",
right: "0px",
}}
navigation={[
{
text: "Copy profile URL",
onClick: (e) =>
this._handleCopy(e, `https://slate.host/${relation.user.username}`),
},
{
text: this.props.viewer?.subscriptions.filter((subscription) => {
return subscription.target_user_id === relation.target_user_id;
}).length
? "Unfollow"
: "Follow",
onClick: this.props.viewer
? (e) => this._handleFollow(e, relation.target_user_id)
: () => this.setState({ visible: true }),
},
]}
/>
)}
<PopoverNavigation
style={{
top: "40px",
right: "0px",
}}
navigation={[
{
text: this.props.viewer?.subscriptions.filter((subscription) => {
return subscription.target_user_id === relation.target_user_id;
}).length
? "Unfollow"
: "Follow",
onClick: this.props.viewer
? (e) => this._handleFollow(e, relation.target_user_id)
: () => this.setState({ visible: true }),
},
]}
/>
</Boundary>
) : null}
</div>
@ -411,45 +390,24 @@ export default class Profile extends React.Component {
enabled
onOutsideRectEvent={(e) => this._handleClick(e, relation.id)}
>
{relation.owner_user_id === this.props.viewer?.id ? (
<PopoverNavigation
style={{
top: "40px",
right: "0px",
}}
navigation={[
{
text: "Copy profile URL",
onClick: (e) =>
this._handleCopy(e, `https://slate.host/${relation.owner.username}`),
},
]}
/>
) : (
<PopoverNavigation
style={{
top: "40px",
right: "0px",
}}
navigation={[
{
text: "Copy profile URL",
onClick: (e) =>
this._handleCopy(e, `https://slate.host/${relation.owner.username}`),
},
{
text: this.props.viewer?.subscriptions.filter((subscription) => {
return subscription.target_user_id === relation.owner_user_id;
}).length
? "Unfollow"
: "Follow",
onClick: this.props.viewer
? (e) => this._handleFollow(e, relation.owner_user_id)
: () => this.setState({ visible: true }),
},
]}
/>
)}
<PopoverNavigation
style={{
top: "40px",
right: "0px",
}}
navigation={[
{
text: this.props.viewer?.subscriptions.filter((subscription) => {
return subscription.target_user_id === relation.owner_user_id;
}).length
? "Unfollow"
: "Follow",
onClick: this.props.viewer
? (e) => this._handleFollow(e, relation.owner_user_id)
: () => this.setState({ visible: true }),
},
]}
/>
</Boundary>
) : null}
</div>

View File

@ -122,7 +122,7 @@ export default class SlateMediaObjectPreview extends React.Component {
if (this.props.centeredImage) {
return (
<React.Fragment>
{this.state.showImage ? (
{this.state.showImage || !blurhash ? (
<div
css={STYLES_IMAGE_CONTAINER}
style={{
@ -130,7 +130,7 @@ export default class SlateMediaObjectPreview extends React.Component {
...this.props.imageStyle,
}}
/>
) : blurhash ? (
) : (
<div css={STYLES_BLUR_CONTAINER}>
<Blurhash
hash={blurhash}
@ -142,15 +142,13 @@ export default class SlateMediaObjectPreview extends React.Component {
punch={1}
/>
</div>
) : (
<div css={STYLES_IMAGE_CONTAINER} style={this.props.imageStyle} />
)}
</React.Fragment>
);
}
return (
<React.Fragment>
{this.state.showImage ? (
{this.state.showImage || !blurhash ? (
<img
css={STYLES_IMAGE}
style={{
@ -158,7 +156,7 @@ export default class SlateMediaObjectPreview extends React.Component {
}}
src={url}
/>
) : blurhash ? (
) : (
<Blurhash
hash={blurhash}
width="100%"
@ -167,11 +165,6 @@ export default class SlateMediaObjectPreview extends React.Component {
resolutionY={32}
punch={1}
/>
) : (
<div
css={STYLES_IMAGE}
style={{ maxHeight: "100%", maxWidth: "100%", ...this.props.imageStyle }}
/>
)}
</React.Fragment>
);

View File

@ -2,7 +2,6 @@ import * as React from "react";
import * as Constants from "~/common/constants";
import { css } from "@emotion/react";
import { CineonToneMapping } from "three";
const STYLES_PRIMARY_TAB_GROUP = css`
font-size: ${Constants.typescale.lvl2};

View File

@ -5,46 +5,44 @@ import * as Constants from "~/common/constants";
export default async (req, res) => {
const users = await Data.getEveryUser(false);
for (let user of users) {
if (
user.data &&
user.data.library &&
user.data.library.length &&
user.data.library[0].children
) {
// let library = user.data.library[0].children;
// for (let file of library) {
// delete file.icon;
// if (!file.ipfs) {
// if (file.cid) {
// //do nothing
// }
// } else if (file.ipfs.includes("/ipfs/")) {
// file.cid = Strings.getCIDFromIPFS(file.ipfs);
// } else {
// file.cid = file.ipfs;
// }
// if (file.file) {
// file.name = file.file;
// }
// delete file.error;
// delete file.ipfs;
// if (file.ipfs || !file.cid || file.icon) {
// console.log("FAILED! error: missing cid or has ipfs or has icon");
// console.log(file);
// }
// }
if (user.data?.library[0]?.children?.length) {
let library = user.data.library[0].children;
for (let file of library) {
delete file.icon;
if (!file.cid) {
if (file.ipfs.includes("/ipfs/")) {
file.cid = Strings.getCIDFromIPFS(file.ipfs);
} else {
file.cid = file.ipfs;
}
}
delete file.ipfs;
delete file.retrieval;
delete file.storage;
delete file.job;
delete file.networks;
if (file.file && !file.name) {
file.name = file.file;
}
delete file.error;
if (file.ipfs || !file.cid || file.icon) {
console.log("FAILED! error: missing cid or has ipfs or has icon");
console.log(file);
}
// console.log(file);
}
// let response = Data.updateUserById({ id: user.id, data: user.data });
// if (!response || response.error) {
// console.log(`UPDATE FAILED for user with id ${user.id}`);
// }
// NOTE(martina): uncomment to test
for (let file of user.data.library[0].children) {
if (file.ipfs || !file.cid) {
console.log("FAILED! error: missing cid or has ipfs or has icon");
console.log(file);
}
}
// for (let file of user.data.library[0].children) {
// if (file.ipfs || !file.cid) {
// console.log("FAILED! error: missing cid or has ipfs");
// console.log(file);
// }
// }
}
}
console.log("finished checking");

View File

@ -4,7 +4,6 @@ import * as Strings from "~/common/strings";
import * as Social from "~/node_common/social";
import * as ViewerManager from "~/node_common/managers/viewer";
import * as SearchManager from "~/node_common/managers/search";
import { CompressedPixelFormat } from "three";
const DEFAULT_BUCKET_NAME = "data";

View File

@ -163,22 +163,6 @@ export default class SceneDirectory extends React.Component {
}
};
// _handleDelete = async (e, id) => {
// this._handleHide();
// e.stopPropagation();
// await Actions.deleteTrustRelationship({
// id: id,
// });
// };
// _handleAccept = async (e, id) => {
// this._handleHide();
// e.stopPropagation();
// await Actions.updateTrustRelationship({
// userId: id,
// });
// };
_handleFollow = async (e, id) => {
this._handleHide();
e.stopPropagation();
@ -188,182 +172,6 @@ export default class SceneDirectory extends React.Component {
};
render() {
// let requests = this.props.viewer.pendingTrusted
// .filter((relation) => {
// return !relation.data.verified;
// })
// .map((relation) => {
// let button = (
// <React.Fragment>
// <span css={STYLES_MOBILE_ONLY}>
// <div css={STYLES_BUTTONS}>
// <div
// css={STYLES_ITEM_BOX}
// onClick={(e) => this._handleAccept(e, relation.owner.id)}
// >
// <SVG.CheckBox height="24px" style={{ color: Constants.system.brand }} />
// </div>
// <div
// css={STYLES_ITEM_BOX}
// style={{ marginRight: 0 }}
// onClick={(e) => {
// this._handleDelete(e, relation.id);
// }}
// >
// <SVG.Dismiss height="24px" style={{ color: Constants.system.gray }} />
// </div>
// </div>
// </span>
// <span css={STYLES_MOBILE_HIDDEN}>
// <div css={STYLES_BUTTONS}>
// <ButtonPrimary
// transparent
// style={{ fontSize: 16 }}
// onClick={(e) => this._handleAccept(e, relation.owner.id)}
// >
// Accept
// </ButtonPrimary>
// <ButtonSecondary
// transparent
// style={{ fontSize: 16 }}
// onClick={(e) => {
// this._handleDelete(e, relation.id);
// }}
// >
// Decline
// </ButtonSecondary>
// </div>
// </span>
// </React.Fragment>
// );
// return (
// <UserEntry
// key={relation.id}
// user={relation.owner}
// button={button}
// onClick={() => {
// this.props.onAction({
// type: "NAVIGATE",
// value: this.props.sceneId,
// scene: "PROFILE",
// data: relation.owner,
// });
// }}
// message=" requested to trust you"
// />
// );
// });
// let trusted = this.props.viewer.pendingTrusted
// .filter((relation) => {
// return relation.data.verified;
// })
// .map((relation) => {
// let button = (
// <div css={STYLES_ITEM_BOX} onClick={(e) => this._handleClick(e, relation.id)}>
// <SVG.MoreHorizontal height="24px" />
// {this.state.contextMenu === relation.id ? (
// <Boundary
// captureResize={true}
// captureScroll={false}
// enabled
// onOutsideRectEvent={(e) => this._handleClick(e, relation.id)}
// >
// <PopoverNavigation
// style={{
// top: "40px",
// right: "0px",
// }}
// navigation={[
// {
// text: "Copy profile URL",
// onClick: (e) =>
// this._handleCopy(e, `https://slate.host/${relation.owner.username}`),
// },
// {
// text: "Remove peer",
// onClick: (e) => this._handleDelete(e, relation.id),
// },
// ]}
// />
// </Boundary>
// ) : null}
// </div>
// );
// return (
// <UserEntry
// key={relation.id}
// user={relation.owner}
// button={button}
// onClick={() => {
// this.props.onAction({
// type: "NAVIGATE",
// value: this.props.sceneId,
// scene: "PROFILE",
// data: relation.owner,
// });
// }}
// />
// );
// });
// if (!trusted) {
// trusted = [];
// }
// trusted.push(
// ...this.props.viewer.trusted
// .filter((relation) => {
// return relation.data.verified;
// })
// .map((relation) => {
// let button = (
// <div css={STYLES_ITEM_BOX} onClick={(e) => this._handleClick(e, relation.id)}>
// <SVG.MoreHorizontal height="24px" />
// {this.state.contextMenu === relation.id ? (
// <Boundary
// captureResize={true}
// captureScroll={false}
// enabled
// onOutsideRectEvent={(e) => this._handleClick(e, relation.id)}
// >
// <PopoverNavigation
// style={{
// top: "40px",
// right: "0px",
// }}
// navigation={[
// {
// text: "Copy profile URL",
// onClick: (e) =>
// this._handleCopy(e, `https://slate.host/${relation.user.username}`),
// },
// {
// text: "Remove peer",
// onClick: (e) => this._handleDelete(e, relation.id),
// },
// ]}
// />
// </Boundary>
// ) : null}
// </div>
// );
// return (
// <UserEntry
// key={relation.id}
// user={relation.user}
// button={button}
// onClick={() => {
// this.props.onAction({
// type: "NAVIGATE",
// value: this.props.sceneId,
// scene: "PROFILE",
// data: relation.user,
// });
// }}
// />
// );
// })
// );
let following = this.props.viewer.subscriptions
.filter((relation) => {
return !!relation.target_user_id;
@ -385,11 +193,6 @@ export default class SceneDirectory extends React.Component {
right: "0px",
}}
navigation={[
{
text: "Copy profile URL",
onClick: (e) =>
this._handleCopy(e, `https://slate.host/${relation.user.username}`),
},
{
text: "Unfollow",
onClick: (e) => this._handleFollow(e, relation.user.id),
@ -434,11 +237,6 @@ export default class SceneDirectory extends React.Component {
right: "0px",
}}
navigation={[
{
text: "Copy profile URL",
onClick: (e) =>
this._handleCopy(e, `https://slate.host/${relation.owner.username}`),
},
{
text: this.props.viewer.subscriptions.filter((subscription) => {
return subscription.target_user_id === relation.owner.id;