search websocket reconnect and private slate internal fix

This commit is contained in:
Martina 2021-02-02 20:40:24 -08:00
parent ca4b3bbb49
commit 2f36713692
4 changed files with 23 additions and 6 deletions

View File

@ -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;
}

View File

@ -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(

View File

@ -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({

View File

@ -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>
);