Skip to content

Commit 705679b

Browse files
author
Ives van Hoorne
committed
Do some fixes
1 parent 1f66bc3 commit 705679b

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed

packages/app/src/app/components/CodeEditor/Monaco/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,12 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
412412
this.setCorrections(corrections);
413413
}
414414

415+
this.receivingCode = false;
415416
if (this.props.onCodeReceived) {
416417
// Whenever the user changes a module we set up a state that defines
417418
// that the changes of code are not sent to live users. We need to reset
418419
// this state when we're doing changing modules
419420
this.props.onCodeReceived();
420-
this.receivingCode = false;
421421
}
422422
});
423423
};
@@ -434,6 +434,11 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
434434
* Throttle the changes and handle them after a desired amount of time as one array of changes
435435
*/
436436
addChangesOperation = (changes: Array<any>) => {
437+
// Module changed in the meantime
438+
if (this.changes.moduleShortid !== this.currentModule.shortid) {
439+
this.sendChangeOperations();
440+
}
441+
437442
if (!this.changes.code) {
438443
this.changes.code = this.currentModule.code || '';
439444
}

packages/app/src/app/pages/Live/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ class LivePage extends React.Component {
129129
render() {
130130
const { match, store } = this.props;
131131

132+
store.user;
133+
132134
const content = this.getContent();
133135

134136
if (content) {

packages/app/src/app/pages/Sandbox/Editor/Content/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ class EditorPreview extends React.Component<Props, State> {
214214
store.editor.pendingOperation.map(x => x),
215215
() => {
216216
if (store.editor.pendingOperation) {
217+
if (editor.setReceivingCode) {
218+
editor.setReceivingCode(true);
219+
}
217220
if (editor.applyOperation) {
218221
editor.applyOperation(
219222
TextOperation.fromJSON(store.editor.pendingOperation)
@@ -234,6 +237,9 @@ class EditorPreview extends React.Component<Props, State> {
234237
console.error(e);
235238
}
236239
}
240+
if (editor.setReceivingCode) {
241+
editor.setReceivingCode(false);
242+
}
237243
this.props.signals.live.onOperationApplied();
238244
}
239245
}

packages/app/src/app/store/getters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export function isLoggedIn() {
1111
}
1212

1313
export function hasLogIn() {
14-
return !!store.get('jwt');
14+
return !!this.jwt || !!store.get('jwt');
1515
}

packages/app/src/app/store/modules/live/sequences.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ export const handleMessage = [
256256
actions.disconnect,
257257
set(props`modal`, 'liveSessionEnded'),
258258
openModal,
259+
when(state`live.roomInfo.ownerId`, `live.user.id`, (i1, i2) => i1 === i2),
260+
{
261+
true: [],
262+
false: [set(state`live.editor.currentSandbox.owned`, false)],
263+
},
259264
resetLive,
260265
],
261266
otherwise: [],
@@ -273,7 +278,6 @@ export const createLive = [
273278
export const sendTransform = [actions.sendTransform];
274279

275280
export const applyTransformation = [
276-
actions.setReceivingStatus,
277281
when(
278282
state`editor.currentModuleShortid`,
279283
props`moduleShortid`,

packages/app/src/app/store/sequences.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
removeOptimisticModule,
1212
} from './modules/files/actions';
1313

14+
import { disconnect } from './modules/live/actions';
15+
1416
export const unloadApp = actions.stopListeningToConnectionChange;
1517

1618
export const setConnection = set(state`connected`, props`connection`);
@@ -153,6 +155,12 @@ export const signIn = [
153155
];
154156

155157
export const signOut = [
158+
set(state`workspace.openedWorkspaceItem`, 'files'),
159+
when(state`live.isLive`),
160+
{
161+
true: disconnect,
162+
false: [],
163+
},
156164
actions.signOut,
157165
set(state`jwt`, null),
158166
actions.removeJwtFromStorage,

0 commit comments

Comments
 (0)