11<script setup lang="ts">
22import type { DevframeDockEntry } from ' @devframes/hub'
33import type { DocksContext } from ' @devframes/hub/client'
4- import type { SharedState } from ' devframe/utils/shared-state'
5- import type { DevframeDockEntriesGrouped , DevframeDocksUserSettings } from ' ../../state/dock-settings'
4+ import type { DevframeDockEntriesGrouped } from ' ../../state/dock-settings'
65import { useDraggable } from ' @vueuse/core'
76import { computed , ref , useTemplateRef } from ' vue'
87import { docksGroupByCategories , getCategoryLabel , getGroupMembers , getGroupMembersGrouped , isCategoryHideable } from ' ../../state/dock-settings'
9- import { sharedStateToRef } from ' ../../state/docks '
8+ import { useSettings } from ' ../../state/settings-defaults '
109import HashBadge from ' ../display/HashBadge.vue'
1110import DockIcon from ' ../dock/DockIcon.vue'
1211
1312const props = defineProps <{
1413 context: DocksContext
15- settingsStore: SharedState <DevframeDocksUserSettings >
1614}>()
1715
18- const settings = sharedStateToRef (props .settingsStore )
16+ const settings = useSettings (props .context )
17+ const settingsStore = props .context .docks .settings
1918
2019// Top-level rows are grouped by category with members collapsed under their
2120// group button. A group's members are split by their in-group sub-category, and
@@ -106,7 +105,7 @@ function isInteractiveElement(el: HTMLElement | null): boolean {
106105function applyOrder(container : string , items : DevframeDockEntry []) {
107106 const def = defaultItemsOfContainer (container ).map (i => i .id )
108107 const isDefault = items .length === def .length && items .every ((item , i ) => item .id === def [i ])
109- props . settingsStore .mutate ((state ) => {
108+ settingsStore .mutate ((state ) => {
110109 items .forEach ((item , index ) => {
111110 if (isDefault )
112111 delete state .docksCustomOrder [item .id ]
@@ -185,12 +184,12 @@ function toggleDock(id: string, visible?: boolean) {
185184 const shouldShow = visible ?? isHidden
186185
187186 if (shouldShow ) {
188- props . settingsStore .mutate ((state ) => {
187+ settingsStore .mutate ((state ) => {
189188 state .docksHidden = state .docksHidden .filter ((i : string ) => i !== id )
190189 })
191190 }
192191 else {
193- props . settingsStore .mutate ((state ) => {
192+ settingsStore .mutate ((state ) => {
194193 state .docksHidden = [... state .docksHidden , id ]
195194 })
196195 }
@@ -204,12 +203,12 @@ function toggleCategory(category: string, visible?: boolean) {
204203 const shouldShow = visible ?? isHidden
205204
206205 if (shouldShow ) {
207- props . settingsStore .mutate ((state ) => {
206+ settingsStore .mutate ((state ) => {
208207 state .docksCategoriesHidden = state .docksCategoriesHidden .filter ((i : string ) => i !== category )
209208 })
210209 }
211210 else {
212- props . settingsStore .mutate ((state ) => {
211+ settingsStore .mutate ((state ) => {
213212 state .docksCategoriesHidden = [... state .docksCategoriesHidden , category ]
214213 })
215214 }
@@ -218,12 +217,12 @@ function toggleCategory(category: string, visible?: boolean) {
218217function togglePin(id : string ) {
219218 const pinned = settings .value .docksPinned
220219 if (pinned .includes (id )) {
221- props . settingsStore .mutate ((state ) => {
220+ settingsStore .mutate ((state ) => {
222221 state .docksPinned = state .docksPinned .filter ((i : string ) => i !== id )
223222 })
224223 }
225224 else {
226- props . settingsStore .mutate ((state ) => {
225+ settingsStore .mutate ((state ) => {
227226 state .docksPinned = [... state .docksPinned , id ]
228227 })
229228 }
@@ -273,7 +272,7 @@ function doesContainerHaveCustomOrder(container: string): boolean {
273272
274273function resetCustomOrderForContainer(container : string ) {
275274 const ids = customOrderIdsForContainer (container )
276- props . settingsStore .mutate ((state ) => {
275+ settingsStore .mutate ((state ) => {
277276 ids .forEach ((id ) => {
278277 delete state .docksCustomOrder [id ]
279278 })
0 commit comments