Skip to content

Commit

Permalink
incorporate PR feedback
Browse files Browse the repository at this point in the history
- rename events to `iframe-ready-for-launch-config`, `iframe-launch-config` and `set-theme`
- abstract daily theme parsing into lib method
  • Loading branch information
Regaddi committed Jul 19, 2021
1 parent 7368ed2 commit 23f36cd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
17 changes: 8 additions & 9 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,15 @@ export interface DailyThemeColors {
supportiveText?: string;
}

export type DailyThemeConfig = {
export type DailyTheme = {
colors: DailyThemeColors;
} | {
light: {
colors: DailyThemeColors;
}
dark: {
colors: DailyThemeColors;
}
}
};
export type DailyThemeConfig =
| DailyTheme
| {
light: DailyTheme;
dark: DailyTheme;
};

export interface DailyCallOptions {
url?: string;
Expand Down
32 changes: 24 additions & 8 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ import {
DAILY_CAMERA_ERROR_MIC_IN_USE,
DAILY_CAMERA_ERROR_CAM_AND_MIC_IN_USE,
// events
DAILY_EVENT_READY_FOR_CONFIG,
DAILY_EVENT_IFRAME_CONFIG,
DAILY_EVENT_IFRAME_READY_FOR_LAUNCH_CONFIG,
DAILY_EVENT_IFRAME_LAUNCH_CONFIG,
DAILY_EVENT_SET_THEME,
DAILY_EVENT_LOADING,
DAILY_EVENT_LOADED,
DAILY_EVENT_LOAD_ATTEMPT_FAILED,
Expand Down Expand Up @@ -183,8 +184,9 @@ export {

// events
export {
DAILY_EVENT_READY_FOR_CONFIG,
DAILY_EVENT_IFRAME_CONFIG,
DAILY_EVENT_IFRAME_READY_FOR_LAUNCH_CONFIG,
DAILY_EVENT_IFRAME_LAUNCH_CONFIG,
DAILY_EVENT_SET_THEME,
DAILY_EVENT_LOADING,
DAILY_EVENT_LOADED,
DAILY_EVENT_LOAD_ATTEMPT_FAILED,
Expand Down Expand Up @@ -382,7 +384,10 @@ const FRAME_PROPS = {
return false;
}
if ('light' in o && 'dark' in o) {
return containsValidColors(o.light.colors) && containsValidColors(o.dark.colors);
return (
containsValidColors(o.light.colors) &&
containsValidColors(o.dark.colors)
);
}
return containsValidColors(o.colors);
},
Expand Down Expand Up @@ -1897,7 +1902,7 @@ export default class DailyIframe extends EventEmitter {
...theme,
};
this._messageChannel.sendMessageToDailyJs({
action: DAILY_EVENT_READY_FOR_CONFIG,
action: DAILY_EVENT_SET_THEME,
});
return this;
}
Expand Down Expand Up @@ -2136,10 +2141,21 @@ export default class DailyIframe extends EventEmitter {

handleMessageFromCallMachine(msg) {
switch (msg.action) {
case DAILY_EVENT_READY_FOR_CONFIG:
case DAILY_EVENT_IFRAME_READY_FOR_LAUNCH_CONFIG:
this._messageChannel.sendMessageToCallMachine(
{
action: DAILY_EVENT_IFRAME_LAUNCH_CONFIG,
...this.properties,
},
null,
this._iframe,
this._callFrameId
);
break;
case DAILY_EVENT_SET_THEME:
this._messageChannel.sendMessageToCallMachine(
{
action: DAILY_EVENT_IFRAME_CONFIG,
action: DAILY_EVENT_SET_THEME,
...this.properties,
},
null,
Expand Down
6 changes: 4 additions & 2 deletions src/shared-with-pluot-core/CommonIncludes.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ export const DAILY_CAMERA_ERROR_CAM_AND_MIC_IN_USE = 'cam-mic-in-use';

// events

export const DAILY_EVENT_READY_FOR_CONFIG = 'iframe-ready-for-config';
export const DAILY_EVENT_IFRAME_CONFIG = 'iframe-config';
export const DAILY_EVENT_IFRAME_READY_FOR_LAUNCH_CONFIG =
'iframe-ready-for-launch-config';
export const DAILY_EVENT_IFRAME_LAUNCH_CONFIG = 'iframe-launch-config';
export const DAILY_EVENT_SET_THEME = 'set-theme';
export const DAILY_EVENT_LOADING = 'loading';
export const DAILY_EVENT_LOAD_ATTEMPT_FAILED = 'load-attempt-failed';
export const DAILY_EVENT_LOADED = 'loaded';
Expand Down

0 comments on commit 23f36cd

Please sign in to comment.