chore: Move to prettier standard double quotes (#1309)
This commit is contained in:
@ -1,18 +1,18 @@
|
||||
// @flow
|
||||
import * as React from 'react';
|
||||
import { observable } from 'mobx';
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import { find } from 'lodash';
|
||||
import io from 'socket.io-client';
|
||||
import DocumentsStore from 'stores/DocumentsStore';
|
||||
import CollectionsStore from 'stores/CollectionsStore';
|
||||
import GroupsStore from 'stores/GroupsStore';
|
||||
import MembershipsStore from 'stores/MembershipsStore';
|
||||
import DocumentPresenceStore from 'stores/DocumentPresenceStore';
|
||||
import PoliciesStore from 'stores/PoliciesStore';
|
||||
import ViewsStore from 'stores/ViewsStore';
|
||||
import AuthStore from 'stores/AuthStore';
|
||||
import UiStore from 'stores/UiStore';
|
||||
import * as React from "react";
|
||||
import { observable } from "mobx";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { find } from "lodash";
|
||||
import io from "socket.io-client";
|
||||
import DocumentsStore from "stores/DocumentsStore";
|
||||
import CollectionsStore from "stores/CollectionsStore";
|
||||
import GroupsStore from "stores/GroupsStore";
|
||||
import MembershipsStore from "stores/MembershipsStore";
|
||||
import DocumentPresenceStore from "stores/DocumentPresenceStore";
|
||||
import PoliciesStore from "stores/PoliciesStore";
|
||||
import ViewsStore from "stores/ViewsStore";
|
||||
import AuthStore from "stores/AuthStore";
|
||||
import UiStore from "stores/UiStore";
|
||||
|
||||
export const SocketContext: any = React.createContext();
|
||||
|
||||
@ -37,7 +37,7 @@ class SocketProvider extends React.Component<Props> {
|
||||
if (!process.env.WEBSOCKETS_ENABLED) return;
|
||||
|
||||
this.socket = io(window.location.origin, {
|
||||
path: '/realtime',
|
||||
path: "/realtime",
|
||||
});
|
||||
this.socket.authenticated = false;
|
||||
|
||||
@ -54,38 +54,38 @@ class SocketProvider extends React.Component<Props> {
|
||||
} = this.props;
|
||||
if (!auth.token) return;
|
||||
|
||||
this.socket.on('connect', () => {
|
||||
this.socket.on("connect", () => {
|
||||
// immediately send current users token to the websocket backend where it
|
||||
// is verified, if all goes well an 'authenticated' message will be
|
||||
// received in response
|
||||
this.socket.emit('authentication', {
|
||||
this.socket.emit("authentication", {
|
||||
token: auth.token,
|
||||
});
|
||||
});
|
||||
|
||||
this.socket.on('disconnect', () => {
|
||||
this.socket.on("disconnect", () => {
|
||||
// when the socket is disconnected we need to clear all presence state as
|
||||
// it's no longer reliable.
|
||||
presence.clear();
|
||||
});
|
||||
|
||||
this.socket.on('authenticated', () => {
|
||||
this.socket.on("authenticated", () => {
|
||||
this.socket.authenticated = true;
|
||||
});
|
||||
|
||||
this.socket.on('unauthorized', err => {
|
||||
this.socket.on("unauthorized", err => {
|
||||
this.socket.authenticated = false;
|
||||
ui.showToast(err.message);
|
||||
throw err;
|
||||
});
|
||||
|
||||
this.socket.on('entities', async event => {
|
||||
this.socket.on("entities", async event => {
|
||||
if (event.documentIds) {
|
||||
for (const documentDescriptor of event.documentIds) {
|
||||
const documentId = documentDescriptor.id;
|
||||
let document = documents.get(documentId) || {};
|
||||
|
||||
if (event.event === 'documents.delete') {
|
||||
if (event.event === "documents.delete") {
|
||||
const document = documents.get(documentId);
|
||||
if (document) {
|
||||
document.deletedAt = documentDescriptor.updatedAt;
|
||||
@ -136,7 +136,7 @@ class SocketProvider extends React.Component<Props> {
|
||||
const collectionId = collectionDescriptor.id;
|
||||
const collection = collections.get(collectionId) || {};
|
||||
|
||||
if (event.event === 'collections.delete') {
|
||||
if (event.event === "collections.delete") {
|
||||
documents.removeCollectionDocuments(collectionId);
|
||||
continue;
|
||||
}
|
||||
@ -184,17 +184,17 @@ class SocketProvider extends React.Component<Props> {
|
||||
}
|
||||
});
|
||||
|
||||
this.socket.on('documents.star', event => {
|
||||
this.socket.on("documents.star", event => {
|
||||
documents.starredIds.set(event.documentId, true);
|
||||
});
|
||||
|
||||
this.socket.on('documents.unstar', event => {
|
||||
this.socket.on("documents.unstar", event => {
|
||||
documents.starredIds.set(event.documentId, false);
|
||||
});
|
||||
|
||||
// received when a user is given access to a collection
|
||||
// if the user is us then we go ahead and load the collection from API.
|
||||
this.socket.on('collections.add_user', event => {
|
||||
this.socket.on("collections.add_user", event => {
|
||||
if (auth.user && event.userId === auth.user.id) {
|
||||
collections.fetch(event.collectionId, { force: true });
|
||||
}
|
||||
@ -208,7 +208,7 @@ class SocketProvider extends React.Component<Props> {
|
||||
// received when a user is removed from having access to a collection
|
||||
// to keep state in sync we must update our UI if the user is us,
|
||||
// or otherwise just remove any membership state we have for that user.
|
||||
this.socket.on('collections.remove_user', event => {
|
||||
this.socket.on("collections.remove_user", event => {
|
||||
if (auth.user && event.userId === auth.user.id) {
|
||||
collections.remove(event.collectionId);
|
||||
memberships.removeCollectionMemberships(event.collectionId);
|
||||
@ -220,32 +220,32 @@ class SocketProvider extends React.Component<Props> {
|
||||
|
||||
// received a message from the API server that we should request
|
||||
// to join a specific room. Forward that to the ws server.
|
||||
this.socket.on('join', event => {
|
||||
this.socket.emit('join', event);
|
||||
this.socket.on("join", event => {
|
||||
this.socket.emit("join", event);
|
||||
});
|
||||
|
||||
// received a message from the API server that we should request
|
||||
// to leave a specific room. Forward that to the ws server.
|
||||
this.socket.on('leave', event => {
|
||||
this.socket.emit('leave', event);
|
||||
this.socket.on("leave", event => {
|
||||
this.socket.emit("leave", event);
|
||||
});
|
||||
|
||||
// received whenever we join a document room, the payload includes
|
||||
// userIds that are present/viewing and those that are editing.
|
||||
this.socket.on('document.presence', event => {
|
||||
this.socket.on("document.presence", event => {
|
||||
presence.init(event.documentId, event.userIds, event.editingIds);
|
||||
});
|
||||
|
||||
// received whenever a new user joins a document room, aka they
|
||||
// navigate to / start viewing a document
|
||||
this.socket.on('user.join', event => {
|
||||
this.socket.on("user.join", event => {
|
||||
presence.touch(event.documentId, event.userId, event.isEditing);
|
||||
views.touch(event.documentId, event.userId);
|
||||
});
|
||||
|
||||
// received whenever a new user leaves a document room, aka they
|
||||
// navigate away / stop viewing a document
|
||||
this.socket.on('user.leave', event => {
|
||||
this.socket.on("user.leave", event => {
|
||||
presence.leave(event.documentId, event.userId);
|
||||
views.touch(event.documentId, event.userId);
|
||||
});
|
||||
@ -253,7 +253,7 @@ class SocketProvider extends React.Component<Props> {
|
||||
// received when another client in a document room wants to change
|
||||
// or update it's presence. Currently the only property is whether
|
||||
// the client is in editing state or not.
|
||||
this.socket.on('user.presence', event => {
|
||||
this.socket.on("user.presence", event => {
|
||||
presence.touch(event.documentId, event.userId, event.isEditing);
|
||||
});
|
||||
}
|
||||
@ -275,13 +275,13 @@ class SocketProvider extends React.Component<Props> {
|
||||
}
|
||||
|
||||
export default inject(
|
||||
'auth',
|
||||
'ui',
|
||||
'documents',
|
||||
'collections',
|
||||
'groups',
|
||||
'memberships',
|
||||
'presence',
|
||||
'policies',
|
||||
'views'
|
||||
"auth",
|
||||
"ui",
|
||||
"documents",
|
||||
"collections",
|
||||
"groups",
|
||||
"memberships",
|
||||
"presence",
|
||||
"policies",
|
||||
"views"
|
||||
)(SocketProvider);
|
||||
|
Reference in New Issue
Block a user