Skip to content

Commit 9d68cff

Browse files
christianalfoniCompuIves
authored andcommitted
notification indication, contributors fixed again, changed modu… (codesandbox#2437)
* notification indiation, contributors fixed again, changed modules fixed * fix wrong merge * Fix lint
1 parent 3bb3cf3 commit 9d68cff

File tree

8 files changed

+13
-23
lines changed

8 files changed

+13
-23
lines changed

packages/app/src/app/overmind/effects/api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ export default {
6363
async getSandbox(id: string): Promise<Sandbox> {
6464
const sandbox = await api.get<Sandbox>(`/sandboxes/${id}`);
6565

66-
// We need to add savedCode property to track it
66+
// We need to add client side properties for tracking
6767
return {
6868
...sandbox,
6969
modules: sandbox.modules.map(module => ({
7070
...module,
7171
savedCode: null,
72+
isNotSynced: false,
7273
})),
7374
};
7475
},
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import axios, { AxiosResponse } from 'axios';
1+
import axios from 'axios';
22

33
export default {
44
get: axios.get,
@@ -7,12 +7,4 @@ export default {
77
delete: axios.delete,
88
put: axios.put,
99
request: axios.request,
10-
async getJson<T>(url: string): Promise<AxiosResponse<T>> {
11-
const response = await axios.get(url);
12-
13-
return {
14-
...response,
15-
data: JSON.parse(response.data),
16-
};
17-
},
1810
};

packages/app/src/app/overmind/effects/live/clients.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class CodeSandboxOTClient extends Client {
4040
}
4141

4242
sendOperation(revision, operation) {
43-
this.onSendOperation(revision, operation);
43+
this.onSendOperation(revision, operationToElixir(operation.toJSON()));
4444
}
4545

4646
applyOperation(operation) {
@@ -97,11 +97,7 @@ export default (
9797
initialRevision,
9898
moduleShortid,
9999
(revision, operation) => {
100-
sendOperation(
101-
moduleShortid,
102-
revision,
103-
operationToElixir(operation.toJSON())
104-
);
100+
sendOperation(moduleShortid, revision, operation);
105101
},
106102
operation => {
107103
applyOperation(moduleShortid, operation);

packages/app/src/app/overmind/factories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const withLoadApp = <T>(
5151
state.isAuthenticating = false;
5252

5353
try {
54-
const response = await effects.http.getJson<{
54+
const response = await effects.http.get<{
5555
contributors: Contributor[];
5656
}>(
5757
'https://raw.githubusercontent.com/codesandbox/codesandbox-client/master/.all-contributorsrc'

packages/app/src/app/overmind/namespaces/editor/state.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ type State = {
7272
}
7373
>;
7474
isAdvancedEditor: Derive<State, boolean>;
75-
isModuleSynced: Derive<State, (moduleShortid: string) => boolean>;
7675
shouldDirectoryBeOpen: Derive<State, (directoryShortid: string) => boolean>;
7776
currentDevToolsPosition: {
7877
devToolIndex: number;
@@ -217,8 +216,6 @@ export const state: State = {
217216
? currentPackageJSON.code
218217
: generateFileFromSandbox(currentSandbox);
219218
},
220-
isModuleSynced: ({ changedModuleShortids }) => moduleShortid =>
221-
changedModuleShortids.indexOf(moduleShortid) === -1,
222219
shouldDirectoryBeOpen: ({
223220
currentSandbox,
224221
currentModule,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,9 @@ class EditorPreview extends React.Component {
518518
sandbox={sandbox}
519519
currentTab={currentTab}
520520
currentModule={currentModule}
521-
isModuleSynced={store.editor.isModuleSynced}
521+
isModuleSynced={shortId =>
522+
!store.editor.changedModuleShortids.includes(shortId)
523+
}
522524
width={editorWidth}
523525
height={editorHeight}
524526
settings={settings(store)}

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/DirectoryChildren/ModuleEntry.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ class ModuleEntry extends React.Component {
3838

3939
const liveUsers = store.live.liveUsersByModule[module.shortid] || [];
4040

41-
const isNotSynced = !store.editor.isModuleSynced(module.shortid);
41+
const isNotSynced = store.editor.changedModuleShortids.includes(
42+
module.shortid
43+
);
4244

4345
return (
4446
<Entry

packages/app/src/app/store/modules/editor/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function saveAllModules(store, signals) {
99
// fine-grained control of which saves succeed and which saves fail
1010
if (sandbox.owned) {
1111
sandbox.modules
12-
.filter(m => !store.editor.isModuleSynced(m.shortid))
12+
.filter(m => store.editor.changedModuleShortids.includes(m.shortid))
1313
.forEach(module => {
1414
signals.editor.codeSaved({
1515
code: module.code,

0 commit comments

Comments
 (0)