diff --git a/apps/dumili/api/services/indexation/index.ts b/apps/dumili/api/services/indexation/index.ts index 206d20f56..ee7532115 100644 --- a/apps/dumili/api/services/indexation/index.ts +++ b/apps/dumili/api/services/indexation/index.ts @@ -5,7 +5,7 @@ import type { NamespaceWithData, SessionDataWithIndexation } from "~/index"; import { prisma } from "~/index"; import CoaServices from "~dm-services/coa/types"; import { storyKinds } from "~dumili-types/storyKinds"; -import { getEntryPages } from "~dumili-utils/entryPages"; +import { getEntryFromPage, getEntryPages } from "~dumili-utils/entryPages"; import type { entry, page, @@ -89,12 +89,6 @@ export default (io: Server) => { .use(RequiredAuthMiddleware) .use(getIndexationMiddleware) .on("connection", (indexationSocket) => { - const getEntryFromPage = async (pageId: page["id"]) => - indexationSocket.data.indexation.entries.find(({ id }) => - getEntryPages(indexationSocket.data.indexation, id).some( - ({ id }) => id === pageId, - ), - ); const setInferredEntryStoryKind = async (entryId: entry["id"]) => { const indexation = indexationSocket.data.indexation; @@ -192,11 +186,11 @@ export default (io: Server) => { suggestionId === null ? { disconnect: true } : { - connect: { - id: suggestionId, - indexationId: indexationSocket.data.indexation.id, - }, + connect: { + id: suggestionId, + indexationId: indexationSocket.data.indexation.id, }, + }, }, where: { id: indexationSocket.data.indexation.id, @@ -318,7 +312,7 @@ export default (io: Server) => { const page = indexation.pages.find(({ id }) => id === pageId)!; await setKumikoInferredPageStoryKinds([page]); - const entry = (await getEntryFromPage(pageId))!; + const entry = (getEntryFromPage(indexation, pageId))!; await setInferredEntryStoryKind(entry.id); callback({ status: "OK" }); @@ -461,10 +455,10 @@ const acceptStorySuggestion = async ( suggestionId === null ? { disconnect: true } : { - connect: { - id: suggestionId, - }, + connect: { + id: suggestionId, }, + }, }, where: { id: entryId, @@ -481,10 +475,10 @@ const acceptStoryKindSuggestion = ( suggestionId === null ? { disconnect: true } : { - connect: { - id: suggestionId, - }, + connect: { + id: suggestionId, }, + }, }, where: { id: entryId, diff --git a/apps/dumili/src/components/TableOfContents.vue b/apps/dumili/src/components/TableOfContents.vue index 403a1721a..d40436b56 100644 --- a/apps/dumili/src/components/TableOfContents.vue +++ b/apps/dumili/src/components/TableOfContents.vue @@ -96,8 +96,7 @@ onEntryResizeStop(idx, height) " @click=" - if (entry !== currentEntry) - currentPage = getFirstPageOfEntry(indexation.entries, idx); + currentPage = getFirstPageOfEntry(indexation.entries, entry.id) " > import useAi from "~/composables/useAi"; import { dumiliSocketInjectionKey } from "~/composables/useDumiliSocket"; -import { getFirstPageOfEntry } from "~dumili-utils/entryPages"; +import { + getEntryFromPage, + getFirstPageOfEntry, +} from "~dumili-utils/entryPages"; import { suggestions } from "~/stores/suggestions"; import { ui } from "~/stores/ui"; import { FullEntry, FullIndexation } from "~dumili-services/indexation/types"; @@ -204,15 +206,12 @@ watch( currentPage, (value) => { if (value !== undefined) { - let pagesSoFar = 0; - currentEntry.value = indexation.value.entries.find((entry) => { - if (pagesSoFar >= value) { - return true; - } - pagesSoFar += - entry.entirepages + - entry.brokenpagenumerator / entry.brokenpagedenominator; - })!; + currentEntry.value = getEntryFromPage( + indexation.value!, + indexation.value!.pages.find( + ({ pageNumber }) => pageNumber === value + 1, + )!.id, + )!; } }, { immediate: true }, @@ -276,9 +275,14 @@ watch( } } -.page, -:deep(.resizable) { - box-shadow: 1px 1px #000; +:deep(.entry) { + outline: 1px solid black; + margin-top: 1px; + cursor: pointer; + + &:first-child { + margin-top: 0; + } } :deep(.resizable .handle) { diff --git a/apps/dumili/utils/entryPages.ts b/apps/dumili/utils/entryPages.ts index 91e84029c..a2cb3d8b5 100644 --- a/apps/dumili/utils/entryPages.ts +++ b/apps/dumili/utils/entryPages.ts @@ -1,5 +1,5 @@ import type { FullIndexation } from "~dumili-services/indexation/types"; -import type { entry } from "~prisma/client_dumili"; +import type { entry, page } from "~prisma/client_dumili"; export const getFirstPageOfEntry = (entries: entry[], entryId: number) => Math.floor( @@ -23,3 +23,11 @@ export const getEntryPages = ( firstPageOfEntry + entry.entirepages - 1, ); }; + +export const getEntryFromPage = ( + { entries, pages }: Pick, + pageId: page["id"], +) => + entries.find(({ id }) => + getEntryPages({ entries, pages }, id).some(({ id }) => id === pageId), + );