Skip to content

Commit

Permalink
Fix effect (hackclub#1839)
Browse files Browse the repository at this point in the history
* fix: Remove wrong img value. re hackclub#1579

* revert formating

* revert formating

* revert formating

revert formating

revert formating

* add saving strat and collab on top of existing functionality, by changing a variable in state.ts

* fixed mixup between beta editor and editor

* add files not added previously

* removed repeated file

* solve minor bugs

* add yCollab extention

* change db timestamp instead of calling endpoint(server also changed)

* change state variable responsible for new feature to FALSE

* change saveGame2 name, make feature be enabled by navigating to /~/beta/[id], remove chatty console logs, throw an error if persistence state is not passed, make the signaling server env variable, extract waitInitialUpdate to separate function, make it so if room connection couldn't be established, refresh, add comment block for start-saving endpoint, send 500 if save to db throws error, fix bug where saving strat boolean doesn't change, fix env variable usage

* fix sprig editor bug caused by constantly replacing the editor

* fix thing?

* fix thing?

* fix thing?

* Update yarn.lock

---------

Co-authored-by: GalaxyGamingBoy <[email protected]>
Co-authored-by: Mare Cosmin <[email protected]>
Co-authored-by: Cosmin-Mare <[email protected]>
  • Loading branch information
4 people committed Jun 25, 2024
1 parent e349feb commit 4576be5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/codemirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,19 @@ export default function CodeMirror(props: CodeMirrorProps) {
}
} catch(e){
// DO something
}
}
});
});
});


useSignalEffect(() => {
if(editorRef !== undefined) {
editorRef.destroy()
}
if (!parent.current) throw new Error('Oh golly! The editor parent ref is null')

if(!isNewSaveStrat.value || (props.roomState?.value.roomId === "" || props.persistenceState?.peek().session === null)){
if (!isNewSaveStrat.value || (props.roomState?.peek().roomId === "" || props.persistenceState?.peek().session === null)) {
const editor = new EditorView({
state: createEditorState(props.initialCode ? props.initialCode : '', () => {
if (editor.state.doc.toString() === lastCode) return
Expand All @@ -135,7 +137,7 @@ export default function CodeMirror(props: CodeMirrorProps) {
}
yDoc = new Y.Doc();
console.log(import.meta.env.PUBLIC_SIGNALING_SERVER_HOST)
provider = new WebrtcProvider(props.roomState.value.roomId, yDoc, {
provider = new WebrtcProvider(props.roomState.peek().roomId, yDoc, {
signaling: [
import.meta.env.PUBLIC_SIGNALING_SERVER_HOST,
],
Expand All @@ -161,7 +163,7 @@ export default function CodeMirror(props: CodeMirrorProps) {
//get the initial code from the yjs document
// Wait for document state to be received from provider
let initialUpdate = true;

waitInitialUpdate(initialUpdate).then(() => {
if (ytext.toString() === "") {
ytext.insert(0, lastCode ?? "");
Expand Down

0 comments on commit 4576be5

Please sign in to comment.