Skip to content

Commit

Permalink
chore: refactor constant IS_MAC in a function isMac to prevent SS…
Browse files Browse the repository at this point in the history
…R errors
  • Loading branch information
josdejong committed Jun 4, 2024
1 parent 804b5fd commit 40a6fbe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/lib/components/modals/CopyPasteModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<script lang="ts">
import { getContext } from 'svelte'
import { IS_MAC } from '$lib/utils/navigatorUtils.js'
import { isMac } from '$lib/utils/navigatorUtils.js'
import { onEscape } from '$lib/actions/onEscape.js'
import Header from './Header.svelte'
import type { Context } from 'svelte-simple-modal'
const { close } = getContext<Context>('simple-modal')
const ctrl = IS_MAC ? '' : 'Ctrl'
const ctrl = isMac() ? '' : 'Ctrl'
</script>

<div class="jse-modal jse-copy-paste" use:onEscape={() => close()}>
Expand Down
9 changes: 5 additions & 4 deletions src/lib/utils/navigatorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ declare global {
}
}

export const IS_MAC =
navigator?.platform?.toUpperCase().includes('MAC') ??
navigator?.userAgentData?.platform?.toUpperCase().includes('MAC') ??
false
export function isMac() {
return navigator?.platform?.toUpperCase().includes('MAC') ??
navigator?.userAgentData?.platform?.toUpperCase().includes('MAC') ??
false
}

0 comments on commit 40a6fbe

Please sign in to comment.