Skip to content

Commit

Permalink
applying changes from upstream commits 20e3acf and 561e919 which brok…
Browse files Browse the repository at this point in the history
…e the yarn build (#1)
  • Loading branch information
squatica authored May 27, 2024
1 parent c4d5da3 commit 8f41089
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions excalidraw-app/collab/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { Socket } from "socket.io-client";

class Portal {
collab: TCollabClass;
socket: SocketIOClient.Socket | null = null;
socket: Socket | null = null;
socketInitialized: boolean = false; // we don't want the socket to emit any updates until it is fully initialized
roomId: string | null = null;
roomKey: string | null = null;
Expand All @@ -33,7 +33,7 @@ class Portal {
this.collab = collab;
}

open(socket: SocketIOClient.Socket, id: string, key: string) {
open(socket: Socket, id: string, key: string) {
this.socket = socket;
this.roomId = id;
this.roomKey = key;
Expand Down
3 changes: 2 additions & 1 deletion excalidraw-app/data/StorageBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { SyncableExcalidrawElement } from ".";
import { ExcalidrawElement, FileId } from "../../packages/excalidraw/element/types";
import { AppState, BinaryFileData } from "../../packages/excalidraw/types";
import Portal from "../collab/Portal";
import type { Socket } from "socket.io-client";

export interface StorageBackend {
isSaved: (portal: Portal, elements: readonly ExcalidrawElement[]) => boolean;
Expand All @@ -13,7 +14,7 @@ export interface StorageBackend {
loadFromStorageBackend: (
roomId: string,
roomKey: string,
socket: SocketIOClient.Socket | null,
socket: Socket | null,
) => Promise<readonly ExcalidrawElement[] | null>;
saveFilesToStorageBackend: ({
prefix,
Expand Down
10 changes: 5 additions & 5 deletions excalidraw-app/data/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { MIME_TYPES } from "../../packages/excalidraw/constants";
import { reconcileElements } from "../collab/reconciliation";
import { getSyncableElements, SyncableExcalidrawElement } from ".";
import { ResolutionType } from "../../packages/excalidraw/utility-types";
import { Socket } from "socket.io-client";
import type { Socket } from "socket.io-client";

// private
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -141,12 +141,12 @@ const decryptElements = async (
};

class FirebaseSceneVersionCache {
private static cache = new WeakMap<SocketIOClient.Socket, number>();
static get = (socket: SocketIOClient.Socket) => {
private static cache = new WeakMap<Socket, number>();
static get = (socket: Socket) => {
return FirebaseSceneVersionCache.cache.get(socket);
};
static set = (
socket: SocketIOClient.Socket,
socket: Socket,
elements: readonly SyncableExcalidrawElement[],
) => {
FirebaseSceneVersionCache.cache.set(socket, getSceneVersion(elements));
Expand Down Expand Up @@ -288,7 +288,7 @@ export const saveToFirebase = async (
export const loadFromFirebase = async (
roomId: string,
roomKey: string,
socket: SocketIOClient.Socket | null,
socket: Socket | null,
): Promise<readonly ExcalidrawElement[] | null> => {
const firebase = await loadFirestore();
const db = firebase.firestore();
Expand Down
5 changes: 3 additions & 2 deletions excalidraw-app/data/httpStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import Portal from "../collab/Portal";
import { reconcileElements } from "../collab/reconciliation";
import { StoredScene } from "./StorageBackend";
import type { Socket } from "socket.io-client";

const HTTP_STORAGE_BACKEND_URL = import.meta.env.VITE_APP_HTTP_STORAGE_BACKEND_URL;
const SCENE_VERSION_LENGTH_BYTES = 4
Expand All @@ -25,7 +26,7 @@ const SCENE_VERSION_LENGTH_BYTES = 4
// to prevent modifying upstream files and ease futur maintenance of this fork

const httpStorageSceneVersionCache = new WeakMap<
SocketIOClient.Socket,
Socket,
number
>();

Expand Down Expand Up @@ -106,7 +107,7 @@ export const saveToHttpStorage = async (
export const loadFromHttpStorage = async (
roomId: string,
roomKey: string,
socket: SocketIOClient.Socket | null,
socket: Socket | null,
): Promise<readonly ExcalidrawElement[] | null> => {
const HTTP_STORAGE_BACKEND_URL = import.meta.env.VITE_APP_HTTP_STORAGE_BACKEND_URL;
const getResponse = await fetch(
Expand Down

0 comments on commit 8f41089

Please sign in to comment.