Skip to content

Commit

Permalink
defaults: Reuse default widget manager vars definition where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl authored and ArturoManzoli committed Apr 30, 2024
1 parent 60da9a0 commit 7dcb28a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/assets/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type MiniWidgetProfile, MiniWidgetType } from '@/types/miniWidgets'
import { type Profile, WidgetType } from '@/types/widgets'

const defaultWidgetManagerVars = {
export const defaultWidgetManagerVars = {
timesMounted: 0,
configMenuOpen: false,
allowMoving: false,
Expand All @@ -12,7 +12,7 @@ const defaultWidgetManagerVars = {
highlighted: false,
}

const defaultMiniWidgetManagerVars = {
export const defaultMiniWidgetManagerVars = {
timesMounted: 0,
configMenuOpen: false,
highlighted: false,
Expand Down
7 changes: 2 additions & 5 deletions src/components/EditMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ import { computed, onMounted, ref, toRefs, watch } from 'vue'
import { nextTick } from 'vue'
import { type UseDraggableOptions, useDraggable, VueDraggable } from 'vue-draggable-plus'
import { defaultMiniWidgetManagerVars } from '@/assets/defaults'
import { isHorizontalScroll } from '@/libs/utils'
import { useWidgetManagerStore } from '@/stores/widgetManager'
import { MiniWidgetType } from '@/types/miniWidgets'
Expand Down Expand Up @@ -313,11 +314,7 @@ const availableMiniWidgetTypes = computed(() =>
name: widgetType,
options: {},
hash: uuid(),
managerVars: {
timesMounted: 0,
configMenuOpen: false,
highlighted: false,
},
managerVars: defaultMiniWidgetManagerVars,
}))
)
Expand Down
13 changes: 2 additions & 11 deletions src/stores/widgetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Swal from 'sweetalert2'
import { v4 as uuid4 } from 'uuid'
import { computed, onBeforeMount, onBeforeUnmount, ref, watch } from 'vue'

import { widgetProfiles } from '@/assets/defaults'
import { defaultWidgetManagerVars, widgetProfiles } from '@/assets/defaults'
import { miniWidgetsProfile } from '@/assets/defaults'
import { getKeyDataFromCockpitVehicleStorage, setKeyDataOnCockpitVehicleStorage } from '@/libs/blueos'
import * as Words from '@/libs/funny-name/words'
Expand Down Expand Up @@ -378,16 +378,7 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => {
position: { x: 0.4, y: 0.32 },
size: { width: 0.2, height: 0.36 },
options: {},
managerVars: {
timesMounted: 0,
configMenuOpen: false,
allowMoving: true,
lastNonMaximizedX: 0.4,
lastNonMaximizedY: 0.32,
lastNonMaximizedWidth: 0.2,
lastNonMaximizedHeight: 0.36,
highlighted: false,
},
managerVars: { ...defaultWidgetManagerVars, ...{ allowMoving: true } },
})
}

Expand Down

0 comments on commit 7dcb28a

Please sign in to comment.