{"version":3,"file":"useFile-DL9t4Kj8.js","sources":["../../src/common/fs/utils.ts","../../src/lightspeed/features/files/useFileNotificationState.ts","../../src/lightspeed/features/files/useFile.ts"],"sourcesContent":["import type { FilesystemNodeShortcut, MentionTypeName } from \"@/common/fs/types\";\nimport type { FolderNotificationStateJs, ShortcutNotificationStateJs } from \"@/generated/models\";\nimport { FilesystemNodeType, MentionType } from \"@/common/fs/types\";\nimport { isObject } from \"../lib/guards\";\n\nexport function isShortcutNode(node: unknown): node is FilesystemNodeShortcut {\n return isObject(node) && node.type === FilesystemNodeType.Shortcut && !!node.shortcut;\n}\n\nexport function getUnreadCommentMentions(\n notificationState: ShortcutNotificationStateJs | FolderNotificationStateJs | undefined,\n): number {\n return getUnreadMentions(notificationState, [MentionType.Issue, MentionType.IssueComment]);\n}\n\nexport function getUnreadPublishNotesMentions(\n notificationState: ShortcutNotificationStateJs | FolderNotificationStateJs | undefined,\n): number {\n return getUnreadMentions(notificationState, MentionType.PublishNote);\n}\n\nexport function getUnreadMentions(\n notificationState: ShortcutNotificationStateJs | FolderNotificationStateJs | undefined,\n mentionTypes: MentionTypeName | MentionTypeName[],\n): number {\n let unreadMentionsCount = 0;\n if (notificationState && notificationState.UnreadMentionsCount) {\n const unreadMentions = notificationState.UnreadMentionsCount;\n const types = Array.isArray(mentionTypes) ? [...mentionTypes] : [mentionTypes];\n\n for (const mentionType of types) {\n if (unreadMentions[mentionType]) unreadMentionsCount += unreadMentions[mentionType];\n }\n }\n\n return unreadMentionsCount;\n}\n","import type { FolderNotificationStateJs, ShortcutNotificationStateJs } from \"@/generated/models\";\nimport type { RefOrGetter } from \"ls/common/types\";\nimport { getUnreadCommentMentions, getUnreadPublishNotesMentions } from \"@/common/fs/utils\";\nimport { computed, toValue } from \"vue\";\n\nexport function useFileNotificationState(state: RefOrGetter) {\n const total = computed(() => toValue(state).TotalCommentsCount ?? 0);\n const totalNew = computed(() => toValue(state).NewCommentsCount ?? 0);\n const hasNewComments = computed(() => toValue(state).HasNewComments);\n const unreadCommentMentions = computed(() => getUnreadCommentMentions(toValue(state)));\n const unreadPublishNoteMentions = computed(() => getUnreadPublishNotesMentions(toValue(state)));\n const totalUnreadMentions = computed(() => unreadCommentMentions.value + unreadPublishNoteMentions.value);\n\n return {\n total,\n totalNew,\n hasNewComments,\n totalUnreadMentions,\n unreadCommentMentions,\n unreadPublishNoteMentions,\n };\n}\n","import type { RefOrGetter } from \"ls/common/types\";\nimport { useQuery } from \"@tanstack/vue-query\";\nimport { computed, toValue } from \"vue\";\nimport { queries } from \"./queries\";\n\nexport function useFile(shortcut: RefOrGetter) {\n const options = computed(() => queries.info(toValue(shortcut)));\n const query = useQuery(options);\n\n return query.data;\n}\n"],"names":["getUnreadCommentMentions","notificationState","getUnreadMentions","MentionType","getUnreadPublishNotesMentions","mentionTypes","unreadMentionsCount","unreadMentions","types","mentionType","useFileNotificationState","state","total","computed","toValue","totalNew","hasNewComments","unreadCommentMentions","unreadPublishNoteMentions","totalUnreadMentions","useFile","shortcut","options","queries","useQuery"],"mappings":"sEASO,SAASA,EACdC,EACQ,CACR,OAAOC,EAAkBD,EAAmB,CAACE,EAAY,MAAOA,EAAY,YAAY,CAAC,CAC3F,CAEO,SAASC,EACdH,EACQ,CACD,OAAAC,EAAkBD,EAAmBE,EAAY,WAAW,CACrE,CAEgB,SAAAD,EACdD,EACAI,EACQ,CACR,IAAIC,EAAsB,EACtB,GAAAL,GAAqBA,EAAkB,oBAAqB,CAC9D,MAAMM,EAAiBN,EAAkB,oBACnCO,EAAQ,MAAM,QAAQH,CAAY,EAAI,CAAC,GAAGA,CAAY,EAAI,CAACA,CAAY,EAE7E,UAAWI,KAAeD,EACpBD,EAAeE,CAAW,IAAGH,GAAuBC,EAAeE,CAAW,EACpF,CAGK,OAAAH,CACT,CC/BO,SAASI,EAAyBC,EAA6E,CACpH,MAAMC,EAAQC,EAAS,IAAMC,EAAQH,CAAK,EAAE,oBAAsB,CAAC,EAC7DI,EAAWF,EAAS,IAAMC,EAAQH,CAAK,EAAE,kBAAoB,CAAC,EAC9DK,EAAiBH,EAAS,IAAMC,EAAQH,CAAK,EAAE,cAAc,EAC7DM,EAAwBJ,EAAS,IAAMb,EAAyBc,EAAQH,CAAK,CAAC,CAAC,EAC/EO,EAA4BL,EAAS,IAAMT,EAA8BU,EAAQH,CAAK,CAAC,CAAC,EACxFQ,EAAsBN,EAAS,IAAMI,EAAsB,MAAQC,EAA0B,KAAK,EAEjG,MAAA,CACL,MAAAN,EACA,SAAAG,EACA,eAAAC,EACA,oBAAAG,EACA,sBAAAF,EACA,0BAAAC,CACF,CACF,CChBO,SAASE,EAAQC,EAA+B,CAC/C,MAAAC,EAAUT,EAAS,IAAMU,EAAQ,KAAKT,EAAQO,CAAQ,CAAC,CAAC,EAG9D,OAFcG,EAASF,CAAO,EAEjB,IACf"}