Skip to content

Commit

Permalink
Fix Utilities.host/Utilities.platform
Browse files Browse the repository at this point in the history
Before this fix, "host" would return "undefined" instead of web.
This also fixes OfficeDev#133
  • Loading branch information
Zlatkovsky committed May 6, 2019
1 parent a7b0282 commit 61a8cff
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/helpers/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ function getHostInfo(): {
// when queried from within an add-in.
// If the platform already exposes that info, then just return it
// (but only after massaging it to fit the return types expected by this function)
const context: IContext = ((window as any).Office && (window as any).Office.context) || useHostInfoFallbackLogic();
const isHostExposedNatively =
(window as any).Office &&
(window as any).Office.context &&
(window as any).Office.context.host;
const context: IContext = isHostExposedNatively
? (window as any).Office.context
: useHostInfoFallbackLogic();
return {
host: convertHostValue(context.host),
platform: convertPlatformValue(context.platform)
Expand Down

0 comments on commit 61a8cff

Please sign in to comment.