Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async componentDidMount() {
microsoftTeams.initialize();
microsoftTeams.getContext((context) => {
this.userObjectId = context.userObjectId;
// Initialize application insights for logging events and errors.
this.appInsights = getApplicationInsightsInstance(this.telemetry, browserHistory);
this.getCategory();
});
}
/* Initialize the Teams library before any other SDK calls.
* Initialize throws if called more than once and hence is wrapped in a try-catch to perform a safe initialization.
*/
microsoftTeams.initialize();
}
catch (e) {
}
finally {
this.state = {
groupId: null,
upn: null
};
/** Pass the Context interface to the initialize function below */
microsoftTeams.getContext(context => this.initialize(context as any));
}
}
public componentWillMount() {
this.updateTheme(this.getQueryVariable("theme"));
this.setState({
fontSize: this.pageFontSize()
});
if (this.inTeams()) {
microsoftTeams.initialize();
microsoftTeams.registerOnThemeChangeHandler(this.updateTheme);
microsoftTeams.getContext((context) => {
this.setState({
entityId: context.entityId
});
});
} else {
this.setState({
entityId: "This is not hosted in Microsoft Teams"
});
}
}