Skip to content

Commit

Permalink
fix all TS build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmin-Mare committed Jun 26, 2024
1 parent b57eb25 commit 017db0c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/components/big-interactive-pages/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ export default function Editor({ persistenceState, cookies, roomState }: EditorP
window.addEventListener("keydown", handler);
return () => window.removeEventListener("keydown", handler);
}
return
}, [continueSaving.value]);

let initialCode = "";
Expand Down
9 changes: 5 additions & 4 deletions src/components/codemirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { Signal, useSignal, useSignalEffect } from '@preact/signals'
import { Awareness } from 'y-protocols/awareness'
import { WebrtcProvider } from 'y-webrtc'
import * as Y from 'yjs'
import { saveGame, startSavingGame } from './big-interactive-pages/editor'
import { startSavingGame } from './big-interactive-pages/editor'
import { yCollab } from 'y-codemirror.next'

interface CodeMirrorProps {
class?: string | undefined
persistenceState?: Signal<PersistenceState>
roomState?: Signal<RoomState>
persistenceState: Signal<PersistenceState> | undefined
roomState: Signal<RoomState> | undefined
initialCode?: string
onCodeChange?: () => void
onRunShortcut?: () => void
Expand Down Expand Up @@ -146,7 +146,8 @@ export default function CodeMirror(props: CodeMirrorProps) {

yProviderAwarenessSignal.value = provider.awareness
console.log(props.persistenceState.peek().session?.user)
const isHost = ((props.persistenceState.peek().kind == "PERSISTED" && props.persistenceState.peek().game != "LOADING") && props.persistenceState.peek().session?.user.id === props.persistenceState.peek().game.ownerId)
let persistenceState = props.persistenceState.peek();
const isHost = ((persistenceState.kind == "PERSISTED" && persistenceState.game != "LOADING") && persistenceState.session?.user.id === persistenceState.game.ownerId)
provider.awareness.setLocalStateField("user", {
name:
props.persistenceState.peek().session?.user.email ??
Expand Down
4 changes: 3 additions & 1 deletion src/components/navbar-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const canDelete = (persistenceState: Signal<PersistenceState>) => {

interface EditorNavbarProps {
persistenceState: Signal<PersistenceState>
roomState?: Signal<RoomState>
roomState: Signal<RoomState> | undefined
}

type StuckCategory =
Expand Down Expand Up @@ -228,6 +228,7 @@ export default function EditorNavbar(props: EditorNavbarProps) {
:
props.roomState?.value.participants.filter((participant) => {
if(participant.isHost) return true
return false
})[0]?.userEmail === props.persistenceState.value.session?.user.email ? props.persistenceState.value.session?.user.email : "???"
}`,
SAVING: "Saving...",
Expand Down Expand Up @@ -293,6 +294,7 @@ export default function EditorNavbar(props: EditorNavbarProps) {
<span class={styles.attribution}> by {
(!isNewSaveStrat.value || props.roomState?.value.participants.filter((participant) => {
if(participant.isHost) return true
return false
})[0]?.userEmail === props.persistenceState.value.session?.user.email)
? "you"
: "???"
Expand Down
1 change: 0 additions & 1 deletion src/components/popups-etc/help.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface HelpProps {
defaultHelpAreaHeight: number;
helpAreaSize: Signal<number>;
showingTutorialWarning?: Signal<boolean>;
sessionId: string
}
const helpHtml = compiledContent();

Expand Down
2 changes: 1 addition & 1 deletion src/lib/codemirror/init.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EditorState, Extension } from '@codemirror/state'
import { EditorState } from '@codemirror/state'
import { getSearchQuery, highlightSelectionMatches, search, searchKeymap, setSearchQuery } from '@codemirror/search'
import widgets from './widgets'
import { effect, signal } from '@preact/signals'
Expand Down
12 changes: 9 additions & 3 deletions src/pages/api/games/start-saving.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { APIRoute } from "astro";
import {
getGame,
getSession,
setDocument,
updateDocument,
} from "../../../lib/game-saving/account";
import { updateEmailListLastModifiedTime } from "../../../lib/game-saving/email";
Expand Down Expand Up @@ -34,6 +35,7 @@ export const post: APIRoute = async ({ request, cookies }) => {

let trackingId = game.id;
let trackingType = "game";
const trackingDate = new Date().toDateString()

if (!game.unprotected) {
const session = await getSession(cookies);
Expand All @@ -55,15 +57,19 @@ export const post: APIRoute = async ({ request, cookies }) => {
});

try{
updateDocument("games", gameId, {
await updateDocument("games", gameId, {
tutorialName: tutorialName ?? "",
modifiedAt: Timestamp.now(),
});

await setDocument('daily-edits', `${trackingId}-${trackingDate}`, {
type: trackingType,
id: trackingId,
date: Timestamp.now()
});
return new Response(JSON.stringify({}), { status: 200 })
} catch (error) {
return new Response("Internal server error", { status: 500 })
}

return new Response(JSON.stringify({}), { status: 200 })

};

0 comments on commit 017db0c

Please sign in to comment.