mirror of
https://github.com/filecoin-project/slate.git
synced 2024-09-11 22:07:08 +03:00
search websocket reconnect and private slate internal fix
This commit is contained in:
parent
ca4b3bbb49
commit
2f36713692
@ -168,7 +168,7 @@ export default class ApplicationPage extends React.Component {
|
||||
if (!page || !page.id) {
|
||||
page = { id: "NAV_DATA", scrollTop: 0, data: null };
|
||||
}
|
||||
if (page.id === "NAV_SLATE" && this.state.data?.data?.ownerId === this.props.viewer.id) {
|
||||
if (page.id === "NAV_SLATE" && this.state.data?.data?.ownerId === this.state.viewer.id) {
|
||||
let data = this.state.data;
|
||||
for (let slate of newViewerState.slates) {
|
||||
if (slate.id === data.id) {
|
||||
@ -262,7 +262,7 @@ export default class ApplicationPage extends React.Component {
|
||||
let slate = null;
|
||||
if (
|
||||
current.target.id === "NAV_SLATE" &&
|
||||
this.state.data?.data?.ownerId === this.props.viewer?.id
|
||||
this.state.data?.data?.ownerId === this.state.viewer?.id
|
||||
) {
|
||||
slate = this.state.data;
|
||||
}
|
||||
|
@ -14,8 +14,9 @@ const websocketSend = async (type, data) => {
|
||||
|
||||
const ws = Websocket.get();
|
||||
if (!ws) {
|
||||
NodeLogging.error(`Can not find websocket ...`);
|
||||
return;
|
||||
console.log("no websocket. creating now...");
|
||||
ws = Websocket.create();
|
||||
await Window.delay(2000);
|
||||
}
|
||||
|
||||
const encryptedData = await Utilities.encryptWithSecret(
|
||||
|
@ -20,6 +20,13 @@ export default async (req, res) => {
|
||||
}
|
||||
slate = Serializers.slate(slate);
|
||||
|
||||
if (!slate.data.public && slate.data.ownerId !== req.body.data.id) {
|
||||
return res.status(403).send({
|
||||
decorator: "SLATE_PRIVATE_ACCESS_DENIED",
|
||||
error: true,
|
||||
});
|
||||
}
|
||||
|
||||
let user = await Data.getUserById({ id: slate.data.ownerId });
|
||||
if (!user || user.error) {
|
||||
return res.status(200).send({
|
||||
|
@ -57,6 +57,7 @@ const STYLES_MOBILE_ONLY = css`
|
||||
export default class SceneSlate extends React.Component {
|
||||
state = {
|
||||
notFound: false,
|
||||
accessDenied: false,
|
||||
};
|
||||
|
||||
componentDidMount = async () => {
|
||||
@ -119,6 +120,10 @@ export default class SceneSlate extends React.Component {
|
||||
if (query) {
|
||||
response = await Actions.getSerializedSlate(query);
|
||||
}
|
||||
if (response?.decorator == "SLATE_PRIVATE_ACCESS_DENIED") {
|
||||
this.setState({ accessDenied: true });
|
||||
return;
|
||||
}
|
||||
if (Events.hasError(response)) {
|
||||
this.setState({ notFound: true });
|
||||
return;
|
||||
@ -161,12 +166,16 @@ export default class SceneSlate extends React.Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
if (this.state.notFound) {
|
||||
if (this.state.notFound || this.state.accessDenied) {
|
||||
return (
|
||||
<ScenePage>
|
||||
<EmptyState>
|
||||
<SVG.Layers height="24px" style={{ marginBottom: 24 }} />
|
||||
<div>We were unable to locate that slate</div>
|
||||
<div>
|
||||
{this.state.accessDenied
|
||||
? "You do not have access to that slate"
|
||||
: "We were unable to locate that slate"}
|
||||
</div>
|
||||
</EmptyState>
|
||||
</ScenePage>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user