fix(tag): bug
This commit is contained in:
@@ -5,7 +5,7 @@ import { usePaperStore } from "../usePaperStore"
|
||||
import { usePaperSupportStore } from "../usePaperSupportStore"
|
||||
import { useTopToolsStore } from "../useTopToolsStore"
|
||||
|
||||
const getTagVisibility = (tagCategory?: string) => {
|
||||
const getTagVisibilityByConfig = (tagCategory?: string) => {
|
||||
const { showTags, showTagsConfigs } = useTopToolsStore.getState()
|
||||
if (!showTags) return false
|
||||
if (tagCategory === "mask") return showTagsConfigs.includes("外框")
|
||||
@@ -13,6 +13,16 @@ const getTagVisibility = (tagCategory?: string) => {
|
||||
return true
|
||||
}
|
||||
|
||||
export const getObjectTagVisibility = (
|
||||
imageId: string,
|
||||
objectId: number,
|
||||
tagCategory?: string
|
||||
) => {
|
||||
const { pathStatus } = useObjectStore.getState()
|
||||
if (pathStatus[imageId + objectId]?.HIDE) return false
|
||||
return getTagVisibilityByConfig(tagCategory)
|
||||
}
|
||||
|
||||
const setSelectedItemFalse = (id: number) => {
|
||||
if (!id) return
|
||||
const sameIdItems = usePaperStore.getState().getItemsById(id)
|
||||
@@ -50,7 +60,11 @@ const clearHiddenObjectSelectionState = (imageId: string, objectId: number) => {
|
||||
}
|
||||
}
|
||||
|
||||
const syncObjectItemsVisibility = (objectId: number, hide: boolean) => {
|
||||
const syncObjectItemsVisibility = (
|
||||
imageId: string,
|
||||
objectId: number,
|
||||
hide: boolean
|
||||
) => {
|
||||
const sameIdItems = usePaperStore.getState().getItemsById(objectId)
|
||||
if (!sameIdItems?.length) return
|
||||
sameIdItems.forEach((item) => {
|
||||
@@ -59,7 +73,11 @@ const syncObjectItemsVisibility = (objectId: number, hide: boolean) => {
|
||||
return
|
||||
}
|
||||
if (item.data?.type === "tag") {
|
||||
item.visible = getTagVisibility(item.data?.tag_category)
|
||||
item.visible = getObjectTagVisibility(
|
||||
imageId,
|
||||
objectId,
|
||||
item.data?.tag_category
|
||||
)
|
||||
return
|
||||
}
|
||||
item.visible = true
|
||||
@@ -77,7 +95,7 @@ export const toggleObjectHideByShortcut = (
|
||||
|
||||
if (hide) {
|
||||
updatePathStatus(imageId + objectId, "HIDE", hide)
|
||||
syncObjectItemsVisibility(objectId, hide)
|
||||
syncObjectItemsVisibility(imageId, objectId, hide)
|
||||
setSelectedItemFalse(objectId)
|
||||
clearHiddenObjectSelectionState(imageId, objectId)
|
||||
|
||||
@@ -96,5 +114,5 @@ export const toggleObjectHideByShortcut = (
|
||||
|
||||
updateOperationStatus(imageId + operationId, "HIDE", hide)
|
||||
updatePathStatus(imageId + objectId, "HIDE", hide)
|
||||
syncObjectItemsVisibility(objectId, hide)
|
||||
syncObjectItemsVisibility(imageId, objectId, hide)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user