From 0c25b1299a892483c568e23ed24c92ec725e5484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Tue, 5 Nov 2019 01:59:42 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=A8=20Switch=20Live=20to=20use=20u?= =?UTF-8?q?seOvermind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/overmind/namespaces/live/actions.ts | 11 +- .../Editor/Workspace/items/Live/index.tsx | 116 ++++++++---------- 2 files changed, 60 insertions(+), 67 deletions(-) diff --git a/packages/app/src/app/overmind/namespaces/live/actions.ts b/packages/app/src/app/overmind/namespaces/live/actions.ts index 657a9c170aa..e03cc1a059a 100755 --- a/packages/app/src/app/overmind/namespaces/live/actions.ts +++ b/packages/app/src/app/overmind/namespaces/live/actions.ts @@ -39,9 +39,10 @@ export const roomJoined: AsyncAction<{ state.live.isLoading = false; }); -export const createLiveClicked: AsyncAction<{ - sandboxId: string; -}> = async ({ state, effects, actions }, { sandboxId }) => { +export const createLiveClicked: AsyncAction = async ( + { actions, effects }, + sandboxId +) => { effects.analytics.track('Create Live Session'); const roomId = await effects.api.createLiveRoom(sandboxId); @@ -186,9 +187,9 @@ export const onSendChat: Action<{ message: string }> = ( effects.live.sendChat(message); }; -export const onChatEnabledChange: Action<{ enabled: boolean }> = ( +export const onChatEnabledChange: Action = ( { effects, state }, - { enabled } + enabled ) => { effects.analytics.track('Enable Live Chat'); diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Live/index.tsx b/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Live/index.tsx index c6ae652f221..653949801ce 100644 --- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Live/index.tsx +++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Live/index.tsx @@ -1,54 +1,54 @@ -import { useOvermind } from 'app/overmind'; import React, { FunctionComponent } from 'react'; +import { useOvermind } from 'app/overmind'; + import { Description, ErrorDescription, WorkspaceInputContainer, WorkspaceSubtitle, } from '../../elements'; + import { More } from '../More'; + import LiveButton from './LiveButton'; import LiveInfo from './LiveInfo'; export const Live: FunctionComponent = () => { const { + actions: { + live: { + createLiveClicked, + onAddEditorClicked, + onChatEnabledChange, + onFollow, + onModeChanged, + onRemoveEditorClicked, + onSessionCloseClicked, + onToggleNotificationsHidden, + }, + }, state: { - isLoggedIn, + editor: { + currentSandbox: { id, owned }, + isAllModulesSynced, + }, live: { + followingUserId, isLive, + isLoading, isOwner, isTeam, - roomInfo, liveUserId, - reconnecting, notificationsHidden, - followingUserId, - isLoading, - }, - editor: { - isAllModulesSynced, - currentSandbox: { owned, id }, - }, - }, - actions: { - live: { - onModeChanged, - onAddEditorClicked, - onRemoveEditorClicked, - onSessionCloseClicked, - onToggleNotificationsHidden, - onChatEnabledChange, - onFollow, - createLiveClicked, + reconnecting, + roomInfo, }, + isLoggedIn, }, } = useOvermind(); - const hasUnsyncedModules = !isAllModulesSynced; - const showPlaceHolder = (!isLive && !owned) || !isLoggedIn; - - if (showPlaceHolder) { + if ((!isLive && !owned) || !isLoggedIn) { const message = isLoggedIn ? ( <> You need to own this sandbox to open a live session to collaborate with @@ -66,26 +66,22 @@ export const Live: FunctionComponent = () => {
{isLive ? ( { - onChatEnabledChange({ - enabled: !roomInfo.chatEnabled, - }); - }} + removeEditor={onRemoveEditorClicked} + roomInfo={roomInfo} setFollowing={onFollow} - followingUserId={followingUserId} + setMode={onModeChanged} + toggleChatEnabled={() => onChatEnabledChange(!roomInfo.chatEnabled)} + toggleNotificationsHidden={onToggleNotificationsHidden} /> ) : ( <> @@ -95,29 +91,25 @@ export const Live: FunctionComponent = () => { re doing it live! - <> - Create live room - - To invite others you need to generate a URL that others can join. - + Create live room + + + To invite others you need to generate a URL that others can join. + + + {!isAllModulesSynced && ( + + Save all your files before going live + + )} - {hasUnsyncedModules && ( - - Save all your files before going live - - )} - - { - createLiveClicked({ - sandboxId: id, - }); - }} - isLoading={isLoading} - disable={hasUnsyncedModules} - /> - - + + createLiveClicked(id)} + /> + )}
From a4904cf2f9819ddf9ea73c68dbcad15cdc9f1b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 30 Nov 2019 21:21:10 +0100 Subject: [PATCH 2/3] Resolve discussions --- .../app/pages/Sandbox/Editor/Workspace/items/Live/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Live/index.tsx b/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Live/index.tsx index 653949801ce..4fffdb98941 100644 --- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Live/index.tsx +++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Live/index.tsx @@ -47,8 +47,9 @@ export const Live: FunctionComponent = () => { isLoggedIn, }, } = useOvermind(); + const showPlaceHolder = (!isLive && !owned) || !isLoggedIn; - if ((!isLive && !owned) || !isLoggedIn) { + if (showPlaceHolder) { const message = isLoggedIn ? ( <> You need to own this sandbox to open a live session to collaborate with From a8c21c2f7d43baf7fc974f1429d44f1e6f820150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Tue, 3 Dec 2019 20:14:47 +0100 Subject: [PATCH 3/3] Fix types --- packages/app/src/app/overmind/namespaces/live/actions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/src/app/overmind/namespaces/live/actions.ts b/packages/app/src/app/overmind/namespaces/live/actions.ts index e03cc1a059a..c83410f2913 100755 --- a/packages/app/src/app/overmind/namespaces/live/actions.ts +++ b/packages/app/src/app/overmind/namespaces/live/actions.ts @@ -40,7 +40,7 @@ export const roomJoined: AsyncAction<{ }); export const createLiveClicked: AsyncAction = async ( - { actions, effects }, + { actions, effects, state }, sandboxId ) => { effects.analytics.track('Create Live Session');