Skip to content

Commit

Permalink
refactor(plugin-flow-builder): applay early return
Browse files Browse the repository at this point in the history
  • Loading branch information
Iru89 committed Oct 3, 2024
1 parent aaaae68 commit 4398df1
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@ export function useWebviewContents<T extends MapContentsType>({
const [error, setError] = useState(false)

const updateCurrentLocale = (textContents?: WebviewTextContent[]) => {

Check warning on line 34 in packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts

View check run for this annotation

Codecov / codecov/patch

packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts#L34

Added line #L34 was not covered by tests
if (!textContents || textContents.length === 0) {
console.log('There is no text contents to check the locale')
return

Check warning on line 37 in packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts

View check run for this annotation

Codecov / codecov/patch

packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts#L36-L37

Added lines #L36 - L37 were not covered by tests
}

if (
textContents &&
textContents?.length > 0 &&
textContents[0].content.text.some(text => text.locale === currentLocale)

Check warning on line 41 in packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts

View check run for this annotation

Codecov / codecov/patch

packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts#L41

Added line #L41 was not covered by tests
) {
setCurrentLocale(currentLocale)
return

Check warning on line 44 in packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts

View check run for this annotation

Codecov / codecov/patch

packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts#L43-L44

Added lines #L43 - L44 were not covered by tests
}

const language = currentLocale.split('-')[0]

Check warning on line 47 in packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts

View check run for this annotation

Codecov / codecov/patch

packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts#L47

Added line #L47 was not covered by tests
if (textContents?.[0].content.text.some(text => text.locale === language)) {
if (textContents[0].content.text.some(text => text.locale === language)) {
setCurrentLocale(language)
return

Check warning on line 50 in packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts

View check run for this annotation

Codecov / codecov/patch

packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts#L49-L50

Added lines #L49 - L50 were not covered by tests
}
Expand Down

0 comments on commit 4398df1

Please sign in to comment.