Skip to content

Commit 6e7b61b

Browse files
committed
Extract integration getter in a helper function
1 parent c831eee commit 6e7b61b

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

packages/core/src/js/feedback/integration.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ export const feedbackIntegration = (
3333
};
3434
};
3535

36+
const _getClientIntegration = (): FeedbackIntegration => {
37+
return getClient()?.getIntegrationByName<ReturnType<typeof feedbackIntegration>>(MOBILE_FEEDBACK_INTEGRATION_NAME);
38+
};
39+
3640
export const getFeedbackOptions = (): Partial<FeedbackWidgetProps> => {
37-
const integration = getClient()?.getIntegrationByName<ReturnType<typeof feedbackIntegration>>(
38-
MOBILE_FEEDBACK_INTEGRATION_NAME,
39-
);
41+
const integration = _getClientIntegration();
4042
if (!integration) {
4143
return {};
4244
}
@@ -45,9 +47,7 @@ export const getFeedbackOptions = (): Partial<FeedbackWidgetProps> => {
4547
};
4648

4749
export const getFeedbackButtonOptions = (): Partial<FeedbackButtonProps> => {
48-
const integration = getClient()?.getIntegrationByName<ReturnType<typeof feedbackIntegration>>(
49-
MOBILE_FEEDBACK_INTEGRATION_NAME,
50-
);
50+
const integration = _getClientIntegration();
5151
if (!integration) {
5252
return {};
5353
}
@@ -56,9 +56,7 @@ export const getFeedbackButtonOptions = (): Partial<FeedbackButtonProps> => {
5656
};
5757

5858
export const getColorScheme = (): 'system' | 'light' | 'dark' => {
59-
const integration = getClient()?.getIntegrationByName<ReturnType<typeof feedbackIntegration>>(
60-
MOBILE_FEEDBACK_INTEGRATION_NAME,
61-
);
59+
const integration = _getClientIntegration();
6260
if (!integration) {
6361
return 'system';
6462
}
@@ -67,9 +65,7 @@ export const getColorScheme = (): 'system' | 'light' | 'dark' => {
6765
};
6866

6967
export const getFeedbackLightTheme = (): Partial<FeedbackWidgetTheme> => {
70-
const integration = getClient()?.getIntegrationByName<ReturnType<typeof feedbackIntegration>>(
71-
MOBILE_FEEDBACK_INTEGRATION_NAME,
72-
);
68+
const integration = _getClientIntegration();
7369
if (!integration) {
7470
return {};
7571
}
@@ -78,9 +74,7 @@ export const getFeedbackLightTheme = (): Partial<FeedbackWidgetTheme> => {
7874
};
7975

8076
export const getFeedbackDarkTheme = (): Partial<FeedbackWidgetTheme> => {
81-
const integration = getClient()?.getIntegrationByName<ReturnType<typeof feedbackIntegration>>(
82-
MOBILE_FEEDBACK_INTEGRATION_NAME,
83-
);
77+
const integration = _getClientIntegration();
8478
if (!integration) {
8579
return {};
8680
}

0 commit comments

Comments
 (0)