Skip to content

Commit e488a96

Browse files
started refactoring
1 parent 144dc14 commit e488a96

File tree

5 files changed

+412
-390
lines changed

5 files changed

+412
-390
lines changed

packages/app/src/app/overmind/namespaces/deployment/actions.ts

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@ export const deployWithNetlify: AsyncAction = async ({
2020
}) => {
2121
const sandbox = state.editor.currentSandbox;
2222

23-
if (!sandbox) {
24-
return;
25-
}
26-
2723
state.deployment.deploying = true;
2824
state.deployment.netlifyLogs = null;
2925

30-
const zip = await effects.zip.create(sandbox);
26+
const zip = await effects.zip.create(sandbox.get());
3127

3228
try {
33-
const id = await effects.netlify.deploy(zip.file, sandbox);
29+
const id = await effects.netlify.deploy(zip.file, sandbox.get());
3430
state.deployment.deploying = false;
3531

3632
await actions.deployment.getNetlifyDeploys();
@@ -55,35 +51,30 @@ export const deployWithNetlify: AsyncAction = async ({
5551

5652
export const getNetlifyDeploys: AsyncAction = async ({ state, effects }) => {
5753
const sandbox = state.editor.currentSandbox;
58-
if (!sandbox) {
59-
return;
60-
}
6154

6255
try {
6356
state.deployment.netlifyClaimUrl = await effects.netlify.claimSite(
64-
sandbox.id
57+
sandbox.getId()
6558
);
6659
state.deployment.netlifySite = await effects.netlify.getDeployments(
67-
sandbox.id
60+
sandbox.getId()
6861
);
6962
} catch (error) {
7063
state.deployment.netlifySite = null;
7164
}
7265
};
7366

7467
export const getDeploys: AsyncAction = async ({ state, actions, effects }) => {
75-
if (
76-
!state.user ||
77-
!state.user.integrations.zeit ||
78-
!state.editor.currentSandbox
79-
) {
68+
if (!state.user || !state.user.integrations.zeit) {
8069
return;
8170
}
8271

8372
state.deployment.gettingDeploys = true;
8473

8574
try {
86-
const zeitConfig = effects.zeit.getConfig(state.editor.currentSandbox);
75+
const zeitConfig = effects.zeit.getConfig(
76+
state.editor.currentSandbox.get()
77+
);
8778

8879
state.deployment.hasAlias = !!zeitConfig.alias;
8980
if (zeitConfig.name) {
@@ -108,15 +99,11 @@ export const deployClicked: AsyncAction = async ({
10899
}) => {
109100
const sandbox = state.editor.currentSandbox;
110101

111-
if (!sandbox) {
112-
return;
113-
}
114-
115102
try {
116103
state.deployment.deploying = true;
117-
const zip = await effects.zip.create(sandbox);
104+
const zip = await effects.zip.create(sandbox.get());
118105
const contents = await effects.jsZip.loadAsync(zip.file);
119-
state.deployment.url = await effects.zeit.deploy(contents, sandbox);
106+
state.deployment.url = await effects.zeit.deploy(contents, sandbox.get());
120107
} catch (error) {
121108
actions.internal.handleError({
122109
message: getZeitErrorMessage(error),
@@ -205,11 +192,7 @@ export const aliasDeployment: AsyncAction<string> = async (
205192
{ state, effects, actions },
206193
id
207194
) => {
208-
if (!state.editor.currentSandbox) {
209-
return;
210-
}
211-
212-
const zeitConfig = effects.zeit.getConfig(state.editor.currentSandbox);
195+
const zeitConfig = effects.zeit.getConfig(state.editor.currentSandbox.get());
213196

214197
try {
215198
const url = await effects.zeit.aliasDeployment(id, zeitConfig);

0 commit comments

Comments
 (0)