mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Convert status data to objects
This commit is contained in:
parent
ec8a789c9a
commit
32c0d81bff
1 changed files with 34 additions and 8 deletions
|
|
@ -2,16 +2,42 @@
|
|||
|
||||
|
||||
const statuses = {
|
||||
'✅': 'native',
|
||||
'✳️': 'rosetta',
|
||||
'⏹': 'no-in-progress',
|
||||
'🚫': 'no',
|
||||
'🔶': 'unreported',
|
||||
'native': {
|
||||
icon: '✅',
|
||||
filterLabel: 'Native Support',
|
||||
snakeSlug: 'native',
|
||||
},
|
||||
'rosetta': {
|
||||
icon: '✳️',
|
||||
filterLabel: 'Rosetta',
|
||||
snakeSlug: 'rosetta',
|
||||
},
|
||||
'no-in-progress': {
|
||||
icon: '⏹',
|
||||
filterLabel: 'In Progress',
|
||||
snakeSlug: 'no_in_progress',
|
||||
},
|
||||
'no': {
|
||||
icon: '🚫',
|
||||
filterLabel: 'Unsupported',
|
||||
snakeSlug: 'no',
|
||||
},
|
||||
'unreported': {
|
||||
icon: '🔶',
|
||||
filterLabel: 'Unreported',
|
||||
snakeSlug: 'unreported',
|
||||
}
|
||||
}
|
||||
|
||||
const statusesByIcon = Object.keys( statuses ).reduce( ( acc, key ) => {
|
||||
const status = statuses[ key ]
|
||||
acc[ status.icon ] = key
|
||||
return acc
|
||||
}, {} )
|
||||
|
||||
export function getStatusName ( status ) {
|
||||
for (const key in statuses) {
|
||||
if (status.trim().startsWith( key )) return statuses[key]
|
||||
for (const key in statusesByIcon) {
|
||||
if (status.trim().startsWith( key )) return statusesByIcon[key]
|
||||
}
|
||||
|
||||
throw new Error('Non status matched')
|
||||
|
|
@ -33,4 +59,4 @@ export function getStatusOfScan ( appScan, includeVersion = true ) {
|
|||
}
|
||||
|
||||
|
||||
export default statuses
|
||||
export default statusesByIcon
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue