diff --git a/helpers/devices.js b/helpers/devices.js new file mode 100644 index 0000000..667d978 --- /dev/null +++ b/helpers/devices.js @@ -0,0 +1,37 @@ + +import { getStatusName } from './statuses.js' + + +export const macAppleSiliconStatuses = new Set([ + 'native', + 'rosetta' +]) + +export function deviceSupportsApp ( device, app ) { + + // const statuses = { + // '✅': 'native', + // '✳️': 'rosetta', + // '⏹': 'no-in-progress', + // '🚫': 'no', + // '🔶': 'unreported', + // } + const appStatus = getStatusName( app.text ) + + if ( device.type === 'intel') { + + return true + } + + if ( device.type === 'mac-apple-silicon') { + + return macAppleSiliconStatuses.has( appStatus ) + } + + // if ( device.type === 'ios') { + + // return + // } + + return false +} diff --git a/pages/device/_slug.vue b/pages/device/_slug.vue index a558513..c67036d 100644 --- a/pages/device/_slug.vue +++ b/pages/device/_slug.vue @@ -57,41 +57,7 @@ import Search from '~/components/search.vue' import LinkButton from '~/components/link-button.vue' // import { categories } from '~/helpers/categories.js' -import { getStatusName } from '~/helpers/statuses.js' - -const macAppleSiliconStatuses = new Set([ - 'native', - 'rosetta' -]) - -function deviceSupportsApp ( device, app ) { - - // const statuses = { - // '✅': 'native', - // '✳️': 'rosetta', - // '⏹': 'no-in-progress', - // '🚫': 'no', - // '🔶': 'unreported', - // } - const appStatus = getStatusName( app.text ) - - if ( device.type === 'intel') { - - return true - } - - if ( device.type === 'mac-apple-silicon') { - - return macAppleSiliconStatuses.has( appStatus ) - } - - // if ( device.type === 'ios') { - - // return - // } - - return false -} +import { deviceSupportsApp } from '~/helpers/devices.js' export default { async asyncData ({ params: { slug } }) {