optionally chain _all_ the things

This commit is contained in:
Tamius Han 2020-11-22 22:12:52 +01:00
parent e5f2bde6bc
commit 1858e092a9
4 changed files with 24 additions and 24 deletions

View File

@ -5,7 +5,7 @@
</div>
<div class="flex action-name">
<span v-if="action.cmd && action.cmd.length > 1 || action.cmd[0].action === 'set-ar' && action.userAdded || (action.cmd[0].arg === AspectRatio.Fixed)" class="icon red" @click="removeAction()">🗙</span>
<span v-if="action?.cmd?.length > 1 || action.cmd[0]?.action === 'set-ar' && action.userAdded || (action.cmd[0]?.arg === AspectRatio.Fixed)" class="icon red" @click="removeAction()">🗙</span>
<span v-else class="icon transparent">🗙</span> &nbsp; &nbsp;
<span class="icon" @click="editAction()">🖉</span> &nbsp; &nbsp;
{{action.name}}

View File

@ -60,7 +60,7 @@
<b>Show this action in the following tabs:</b>
</div>
<template v-if="action && action.cmd[0] && action.cmd[0].action !== 'set-ar'">
<template v-if="aaction?.cmd[0]?.action !== 'set-ar'">
<div class="tab-title">Extension settings (global)</div>
<ScopeSettings :scopeOptions="globalScopeOptions"
@show="updateScopes('global', 'show', $event)"
@ -69,7 +69,7 @@
/>
</template>
<template v-if="action && action.cmd[0] && action.cmd[0].action !== 'set-ar'">
<template v-if="action?.cmd[0]?.action !== 'set-ar'">
<div class="tab-title">Site settings (site)</div>
<ScopeSettings :scopeOptions="siteScopeOptions"
@show="updateScopes('site', 'show', $event)"

View File

@ -29,7 +29,7 @@
Crop actions
</div>
<template v-for="(action, index) of settings.active.actions">
<ActionAlt v-if="action.cmd.length === 1 && action.cmd[0].action === 'set-ar'"
<ActionAlt v-if="action.cmd?.length === 1 && action.cmd[0]?.action === 'set-ar'"
:key="index"
:action="action"
@edit="changeShortcut(index)"
@ -41,7 +41,7 @@
Stretch actions
</div>
<template v-for="(action, index) of settings.active.actions">
<ActionAlt v-if="action.cmd.length === 1 && action.cmd[0].action === 'set-stretch'"
<ActionAlt v-if="action.cmd?.length === 1 && action.cmd[0]?.action === 'set-stretch'"
:key="index"
:action="action"
@edit="changeShortcut(index)"
@ -55,7 +55,7 @@
Alignment actions
</div>
<template v-for="(action, index) of settings.active.actions">
<ActionAlt v-if="action.cmd.length === 1 && action.cmd[0].action === 'set-alignment'"
<ActionAlt v-if="action.cmd?.length === 1 && action.cmd[0]?.action === 'set-alignment'"
:key="index"
:action="action"
@edit="changeShortcut(index)"
@ -69,11 +69,11 @@
</div>
<template v-for="(action, index) of settings.active.actions">
<ActionAlt v-if="action.cmd.length === 1 && (
action.cmd[0].action === 'change-zoom' ||
action.cmd[0].action === 'set-zoom' ||
action.cmd[0].action === 'set-pan' ||
action.cmd[0].action === 'pan' ||
action.cmd[0].action === 'set-pan'
action.cmd[0]?.action === 'change-zoom' ||
action.cmd[0]?.action === 'set-zoom' ||
action.cmd[0]?.action === 'set-pan' ||
action.cmd[0]?.action === 'pan' ||
action.cmd[0]?.action === 'set-pan'
)"
:key="index"
:action="action"
@ -88,14 +88,14 @@
</div>
<template v-for="(action, index) of settings.active.actions">
<ActionAlt v-if="action.cmd.length > 1 || (
action.cmd[0].action !== 'change-zoom' &&
action.cmd[0].action !== 'set-zoom' &&
action.cmd[0].action !== 'set-pan' &&
action.cmd[0].action !== 'pan' &&
action.cmd[0].action !== 'set-pan' &&
action.cmd[0].action !== 'set-alignment' &&
action.cmd[0].action !== 'set-stretch' &&
action.cmd[0].action !== 'set-ar'
action.cmd[0]?.action !== 'change-zoom' &&
action.cmd[0]?.action !== 'set-zoom' &&
action.cmd[0]?.action !== 'set-pan' &&
action.cmd[0]?.action !== 'pan' &&
action.cmd[0]?.action !== 'set-pan' &&
action.cmd[0]?.action !== 'set-alignment' &&
action.cmd[0]?.action !== 'set-stretch' &&
action.cmd[0]?.action !== 'set-ar'
)"
:key="index"
:action="action"

View File

@ -31,7 +31,7 @@
<div class="flex flex-row flex-wrap">
<ShortcutButton v-for="(action, index) of aardActions"
class="flex flex-grow button"
:class="{'setting-selected': getCurrent('autoar') === action.cmd[0].arg}"
:class="{'setting-selected': getCurrent('autoar') === action.cmd[0]?.arg}"
:key="index"
:label="(action.scopes[scope] && action.scopes[scope].label) ? action.scopes[scope].label : action.label"
:shortcut="parseShortcut(action)"
@ -50,7 +50,7 @@
<div class="flex flex-row flex-wrap">
<ShortcutButton v-for="(action, index) of cropModePersistenceActions"
class="flex flex-grow button b3"
:class="{'setting-selected': getCurrent('cropModePersistence') === action.cmd[0].arg}"
:class="{'setting-selected': getCurrent('cropModePersistence') === action.cmd[0]?.arg}"
:key="index"
:label="(action.scopes[scope] && action.scopes[scope].label) ? action.scopes[scope].label : action.label"
:shortcut="parseShortcut(action)"
@ -66,7 +66,7 @@
<div class="flex flex-row flex-wrap">
<ShortcutButton v-for="(action, index) of stretchActions"
class="flex b3 flex-grow button"
:class="{'setting-selected': getCurrent('stretch') === action.cmd[0].arg}"
:class="{'setting-selected': getCurrent('stretch') === action.cmd[0]?.arg}"
:key="index"
:label="(action.scopes[scope] && action.scopes[scope].label) ? action.scopes[scope].label : action.label"
:shortcut="parseShortcut(action)"
@ -81,7 +81,7 @@
<div class="flex flex-row flex-wrap">
<ShortcutButton v-for="(action, index) of keyboardActions"
class="flex b3 flex-grow button"
:class="{'setting-selected': getCurrent('keyboardShortcutsEnabled') === action.cmd[0].arg}"
:class="{'setting-selected': getCurrent('keyboardShortcutsEnabled') === action.cmd[0]?.arg}"
:key="index"
:label="(action.scopes[scope] && action.scopes[scope].label) ? action.scopes[scope].label : action.label"
:shortcut="parseShortcut(action)"
@ -96,7 +96,7 @@
<div class="flex flex-row flex-wrap">
<ShortcutButton v-for="(action, index) of alignmentActions"
class="flex b3 flex-grow button"
:class="{'setting-selected': getCurrent('videoAlignment') === action.cmd[0].arg}"
:class="{'setting-selected': getCurrent('videoAlignment') === action.cmd[0]?.arg}"
:key="index"
:label="(action.scopes[scope] && action.scopes[scope].label) ? action.scopes[scope].label : action.label"
:shortcut="parseShortcut(action)"