diff --git a/frontend/apps/desktop/src/app-comments.ts b/frontend/apps/desktop/src/app-comments.ts
index 0ade133a..42fc3db6 100644
--- a/frontend/apps/desktop/src/app-comments.ts
+++ b/frontend/apps/desktop/src/app-comments.ts
@@ -19,11 +19,11 @@ export const commentsApi = t.router({
getCommentDrafts: t.procedure
.input(
z.object({
- docEid: z.string(),
+ docUid: z.string(),
}),
)
.query(({input}) => {
- const result = commentDraftStore.get(`Doc-${input.docEid}`)
+ const result = commentDraftStore.get(`Doc-${input.docUid}`)
if (!result) return []
const commentIds = Object.keys(result)
return commentIds
@@ -40,7 +40,7 @@ export const commentsApi = t.router({
createCommentDraft: t.procedure
.input(
z.object({
- targetDocEid: z.string(),
+ targetDocUid: z.string(),
targetDocVersion: z.string(),
targetCommentId: z.string().or(z.null()),
blocks: z.array(z.any()).optional(),
@@ -48,14 +48,14 @@ export const commentsApi = t.router({
)
.mutation(async ({input}) => {
const draftId = Math.random().toString(36).slice(2)
- const prevIndex = commentDraftStore.get(`Doc-${input.targetDocEid}`) || {}
- commentDraftStore.set(`Doc-${input.targetDocEid}`, {
+ const prevIndex = commentDraftStore.get(`Doc-${input.targetDocUid}`) || {}
+ commentDraftStore.set(`Doc-${input.targetDocUid}`, {
...prevIndex,
[draftId]: true,
})
commentDraftStore.set(`Comment-${draftId}`, {
blocks: input.blocks || [],
- targetDocEid: input.targetDocEid,
+ targetDocUid: input.targetDocUid,
targetDocVersion: input.targetDocVersion,
targetCommentId: input.targetCommentId,
})
@@ -82,7 +82,7 @@ export const commentsApi = t.router({
.input(
z.object({
commentId: z.string(),
- // targetDocEid: z.string(),
+ // targetDocUid: z.string(),
}),
)
.mutation(async ({input}) => {
@@ -90,9 +90,9 @@ export const commentsApi = t.router({
const comment = commentDraftStore.get(`Comment-${commentId}`)
if (!comment) throw new Error('Comment with this commentId not found')
commentDraftStore.delete(`Comment-${commentId}`)
- const index = commentDraftStore.get(`Doc-${comment.targetDocEid}`)
+ const index = commentDraftStore.get(`Doc-${comment.targetDocUid}`)
if (!index) throw new Error('Comment index not found')
- commentDraftStore.set(`Doc-${comment.targetDocEid}`, {
+ commentDraftStore.set(`Doc-${comment.targetDocUid}`, {
...index,
[commentId]: undefined,
})
diff --git a/frontend/apps/desktop/src/app-diagnosis.ts b/frontend/apps/desktop/src/app-diagnosis.ts
index fff57471..ceea1ffa 100644
--- a/frontend/apps/desktop/src/app-diagnosis.ts
+++ b/frontend/apps/desktop/src/app-diagnosis.ts
@@ -35,7 +35,7 @@ export const diagnosisApi = t.router({
.mutation(async ({input}) => {
const id = unpackHmId(input.draftId)
if (!id) throw new Error('Invalid draftId')
- const draftPath = draftFilePath(id.eid)
+ const draftPath = draftFilePath(id.uid)
// @ts-ignore
const logExist: boolean = await exists(draftPath)
if (!logExist) {
@@ -54,16 +54,16 @@ export const diagnosisApi = t.router({
.mutation(async ({input}) => {
const id = unpackHmId(input.draftId)
if (!id) throw new Error('Invalid draftId')
- const draftPath = draftFilePath(id.eid)
+ const draftPath = draftFilePath(id.uid)
await appendFile(draftPath, JSON.stringify(input.event) + '\n')
- const pubFilePath = createPubFilePath(id.eid)
+ const pubFilePath = createPubFilePath(id.uid)
await move(draftPath, pubFilePath)
return pubFilePath
}),
openDraftLog: t.procedure.input(z.string()).mutation(async ({input}) => {
const id = unpackHmId(input)
if (!id) throw new Error('Invalid draftId')
- await open(draftFilePath(id.eid))
+ await open(draftFilePath(id.uid))
}),
openDraftLogFolder: t.procedure.mutation(async () => {
await open(`${userDataPath}/DraftLog`)
diff --git a/frontend/apps/desktop/src/changes-list.tsx b/frontend/apps/desktop/src/changes-list.tsx
index b4fb25a5..ee3bd82a 100644
--- a/frontend/apps/desktop/src/changes-list.tsx
+++ b/frontend/apps/desktop/src/changes-list.tsx
@@ -10,9 +10,9 @@ import {NavRoute} from '@/utils/routes'
import {useNavigate} from '@/utils/useNavigate'
import {
Change,
- createHmId,
createPublicWebHmUrl,
formattedDateLong,
+ packHmId,
unpackHmId,
} from '@shm/shared'
import {hmId, UnpackedHypermediaId} from '@shm/shared/src/utils/entity-id-url'
@@ -84,7 +84,7 @@ function ChangeItem({
const navigate = useNavigate()
const openAccount = (e) => {
e.stopPropagation()
- navigate({key: 'document', id: hmId('a', change.author)})
+ navigate({key: 'document', id: hmId('d', change.author)})
}
const navRoute = useNavRoute()
const isActive = new Set(activeVersion?.split('.') || []).has(change.id)
@@ -124,7 +124,7 @@ function ChangeItem({
const gwUrl = useGatewayUrl()
const publicWebUrl =
parsedEntityId &&
- createPublicWebHmUrl(parsedEntityId?.type, parsedEntityId?.eid, {
+ createPublicWebHmUrl(parsedEntityId?.type, parsedEntityId?.uid, {
version: change.id,
hostname: gwUrl.data,
})
@@ -146,9 +146,11 @@ function ChangeItem({
icon: ArrowUpRight,
onPress: () => {
open(
- createHmId(parsedEntityId.type, parsedEntityId.eid, {
- version: change.id,
- }),
+ packHmId(
+ hmId(parsedEntityId.type, parsedEntityId.uid, {
+ version: change.id,
+ }),
+ ),
true,
)
},
diff --git a/frontend/apps/desktop/src/components/account-link-avatar.tsx b/frontend/apps/desktop/src/components/account-link-avatar.tsx
index 2fc43a18..75e9d4bd 100644
--- a/frontend/apps/desktop/src/components/account-link-avatar.tsx
+++ b/frontend/apps/desktop/src/components/account-link-avatar.tsx
@@ -85,7 +85,7 @@ export function BaseAccountLinkAvatar({
e.preventDefault()
e.stopPropagation()
if (!accountId) return appError('No account ready to load')
- navigate({key: 'document', id: hmId('a', accountId)})
+ navigate({key: 'document', id: hmId('d', accountId)})
}}
position="relative"
height={size}
diff --git a/frontend/apps/desktop/src/components/app-embeds.tsx b/frontend/apps/desktop/src/components/app-embeds.tsx
index 7964d1ae..1db73025 100644
--- a/frontend/apps/desktop/src/components/app-embeds.tsx
+++ b/frontend/apps/desktop/src/components/app-embeds.tsx
@@ -11,11 +11,11 @@ import {
EntityComponentProps,
InlineEmbedComponentProps,
UnpackedHypermediaId,
- createHmId,
formattedDateMedium,
getBlockNodeById,
getDocumentTitle,
hmId,
+ packHmId,
unpackHmId,
useDocContentContext,
} from '@shm/shared'
@@ -80,7 +80,7 @@ function EmbedWrapper({
useEffect(() => {
const val =
- (routeParams?.documentId == unpackRef?.qid &&
+ (routeParams?.documentId == unpackRef?.id &&
routeParams?.version == unpackRef?.version &&
comment) ||
false
@@ -96,7 +96,7 @@ function EmbedWrapper({
routeParams?.documentId,
routeParams?.version,
comment,
- unpackRef?.qid,
+ unpackRef?.id,
unpackRef?.version,
])
@@ -424,7 +424,7 @@ export function EmbedDocContent(props: EntityComponentProps) {
size="$2"
icon={ArrowUpRightSquare}
onPress={() => {
- if (!props.qid) return
+ if (!props.id) return
navigate({
key: 'document',
id: props,
@@ -439,7 +439,7 @@ export function EmbedDocContent(props: EntityComponentProps) {
}
export function EmbedDocumentCard(props: EntityComponentProps) {
- const docId = props.type == 'd' ? createHmId('d', props.eid) : undefined
+ const docId = props.type == 'd' ? packHmId(hmId('d', props.uid)) : undefined
const doc = useEntity(props)
let textContent = useMemo(() => {
if (doc.data?.document?.content) {
@@ -472,13 +472,10 @@ export function EmbedAccount(
props: EntityComponentProps,
parentBlockId: string | null,
) {
- const profile = useEntity(props)
+ const entity = useEntity(props)
- if (profile.status == 'success') {
- const account =
- profile.data?.type === 'a' ? profile.data?.account : undefined
- if (!account) return null
- if (props.block?.attributes?.view == 'content' && profile.data) {
+ if (entity.status == 'success') {
+ if (props.block?.attributes?.view == 'content' && entity.data) {
return
} else if (props.block?.attributes?.view == 'card') {
return (
@@ -511,9 +508,9 @@ export function EmbedAccount(
}
export function EmbedComment(props: EntityComponentProps) {
- if (props?.type !== 'c')
+ if (props?.type !== 'comment')
throw new Error('Invalid props as ref for EmbedComment')
- const comment = useComment(createHmId('c', props.eid), {
+ const comment = useComment(hmId('comment', props.uid), {
enabled: !!props,
})
let embedBlocks = useMemo(() => {
@@ -583,10 +580,8 @@ function AvatarComponent({accountId}: {accountId: string}) {
}
export function EmbedInline(props: InlineEmbedComponentProps) {
- if (props?.type == 'a') {
- return
- } else if (props?.type == 'd') {
- return
+ if (props?.type == 'd') {
+ return
} else {
console.error('Inline Embed Error', JSON.stringify(props))
return ??
@@ -594,7 +589,7 @@ export function EmbedInline(props: InlineEmbedComponentProps) {
}
function AccountInlineEmbed(props: InlineEmbedComponentProps) {
- const accountId = props?.type == 'a' ? props.eid : undefined
+ const accountId = props?.type == 'd' ? props.uid : undefined
if (!accountId)
throw new Error('Invalid props at AccountInlineEmbed (accountId)')
const accountQuery = useAccount_deprecated(accountId)
@@ -602,7 +597,7 @@ function AccountInlineEmbed(props: InlineEmbedComponentProps) {
return (
navigate({key: 'document', id: hmId('a', accountId)})}
+ onPress={() => navigate({key: 'document', id: hmId('d', accountId)})}
>
{(accountId &&
accountQuery.status == 'success' &&
@@ -612,9 +607,9 @@ function AccountInlineEmbed(props: InlineEmbedComponentProps) {
)
}
-function PublicationInlineEmbed(props: InlineEmbedComponentProps) {
- const pubId = props?.type == 'd' ? props.qid : undefined
- if (!pubId) throw new Error('Invalid props at PublicationInlineEmbed (pubId)')
+function DocInlineEmbed(props: InlineEmbedComponentProps) {
+ const pubId = props?.type == 'd' ? props.id : undefined
+ if (!pubId) throw new Error('Invalid props at DocInlineEmbed (pubId)')
const doc = useEntity(props)
const navigate = useNavigate()
return (
diff --git a/frontend/apps/desktop/src/components/citations.tsx b/frontend/apps/desktop/src/components/citations.tsx
index de5cba4d..ba19cab4 100644
--- a/frontend/apps/desktop/src/components/citations.tsx
+++ b/frontend/apps/desktop/src/components/citations.tsx
@@ -64,7 +64,7 @@ function PublicationCitationItem({mention}: {mention: Mention}) {
const docTextContent = useDocTextContent(doc.data?.document)
const destRoute: DocumentRoute = {
key: 'document',
- documentId: unpackedSource!.qid,
+ documentId: unpackedSource!.id,
versionId: mention.sourceBlob?.cid,
blockId: mention.sourceContext,
}
@@ -149,7 +149,7 @@ function CommentCitationItem({mention}: {mention: Mention}) {
if (commentTarget) {
spawn({
key: 'document',
- documentId: commentTarget.qid,
+ documentId: commentTarget.id,
versionId: commentTarget.version || undefined,
})
}
diff --git a/frontend/apps/desktop/src/components/comments.tsx b/frontend/apps/desktop/src/components/comments.tsx
index b1c266c0..79b08a4a 100644
--- a/frontend/apps/desktop/src/components/comments.tsx
+++ b/frontend/apps/desktop/src/components/comments.tsx
@@ -11,9 +11,10 @@ import {
HMComment,
StateStream,
UnpackedHypermediaId,
- createHmId,
formattedDateMedium,
getDocumentTitle,
+ hmId,
+ packHmId,
serializeBlockRange,
unpackHmId,
} from '@shm/shared'
@@ -49,11 +50,11 @@ import {WindowsLinuxWindowControls} from './window-controls'
export function CommentGroup({
group,
- targetDocEid,
+ targetDocUid,
targetDocVersion,
}: {
group: CommentGroup
- targetDocEid: string
+ targetDocUid: string
targetDocVersion: string
}) {
const createComment = useCreateComment()
@@ -81,7 +82,7 @@ export function CommentGroup({
label: 'Reply',
icon: Reply,
onPress: () => {
- createComment(targetDocEid, targetDocVersion, comment.id)
+ createComment(targetDocUid, targetDocVersion, comment.id)
},
},
{
@@ -111,12 +112,14 @@ export function CommentGroup({
const quotingCommentId = unpackHmId(comment.id)
if (!targetId || !quotingCommentId) return
createComment(
- targetDocEid,
+ targetDocUid,
targetDocVersion,
lastComment.id,
- createHmId('c', quotingCommentId.eid, {
- blockRef: blockId,
- }),
+ packHmId(
+ hmId('comment', quotingCommentId.uid, {
+ blockRef: blockId,
+ }),
+ ),
)
}}
/>
@@ -148,7 +151,7 @@ export function CommentGroup({
onPress={() => {
const lastComment = group.comments.at(-1)
if (!lastComment) return
- createComment(targetDocEid, targetDocVersion, lastComment.id)
+ createComment(targetDocUid, targetDocVersion, lastComment.id)
}}
icon={Reply}
>
@@ -162,14 +165,14 @@ export function CommentGroup({
export function CommentThread({
targetCommentId,
- targetDocEid,
+ targetDocUid,
onReplyBlock,
}: {
targetCommentId: string
- targetDocEid: string
+ targetDocUid: string
onReplyBlock: (commentId: string, blockId: string) => void
}) {
- const thread = useCommentReplies(targetCommentId, targetDocEid)
+ const thread = useCommentReplies(targetCommentId, targetDocUid)
return (
<>
@@ -198,7 +201,7 @@ export function EntityCommentsAccessory({
activeVersion: string
}) {
const navigate = useNavigate()
- const commentGroups = useDocumentCommentGroups(id.eid)
+ const commentGroups = useDocumentCommentGroups(id.uid)
const createComment = trpc.comments.createCommentDraft.useMutation()
return (
{
createComment
.mutateAsync({
- targetDocEid: id.eid,
+ targetDocUid: id.uid,
targetDocVersion: activeVersion,
targetCommentId: null,
})
@@ -233,7 +236,7 @@ export function EntityCommentsAccessory({
))}
diff --git a/frontend/apps/desktop/src/components/contacts-prompt.tsx b/frontend/apps/desktop/src/components/contacts-prompt.tsx
index 51dc67e8..cd976b30 100644
--- a/frontend/apps/desktop/src/components/contacts-prompt.tsx
+++ b/frontend/apps/desktop/src/components/contacts-prompt.tsx
@@ -35,7 +35,7 @@ function AddConnectionForm({
const [peerText, setPeer] = useState('')
const daemonInfo = useDaemonInfo()
const account = useMyAccount_deprecated()
- const profile = useEntity(account ? hmId('a', account) : undefined)
+ const profile = useEntity(account ? hmId('d', account) : undefined)
const deviceId = daemonInfo.data?.peerId
const peerInfo = usePeerInfo(deviceId)
console.log('peerInfo', peerInfo.data, deviceId)
diff --git a/frontend/apps/desktop/src/components/copy-gateway-reference.tsx b/frontend/apps/desktop/src/components/copy-gateway-reference.tsx
index 41074be4..966c6043 100644
--- a/frontend/apps/desktop/src/components/copy-gateway-reference.tsx
+++ b/frontend/apps/desktop/src/components/copy-gateway-reference.tsx
@@ -6,8 +6,9 @@ import {
writeableStateStream,
} from '@shm/shared'
import {
- createHmId,
createPublicWebHmUrl,
+ hmId,
+ packHmId,
} from '@shm/shared/src/utils/entity-id-url'
import {
Button,
@@ -49,11 +50,10 @@ export function useCopyGatewayReference() {
const pushOnCopy = usePushOnCopy()
const push = usePushPublication()
function onCopy(input: UnpackedHypermediaId) {
- const publicUrl = createPublicWebHmUrl(input.type, input.eid, {
+ const publicUrl = createPublicWebHmUrl(input.type, input.uid, {
version: input.version,
blockRef: input.blockRef,
blockRange: input.blockRange,
- variants: input.variants,
hostname: gatewayUrl.data,
})
const [setIsPublished, isPublished] =
@@ -63,7 +63,7 @@ export function useCopyGatewayReference() {
fetchWebLinkMeta(publicUrl)
.then((meta) => {
// toast.success(JSON.stringify(meta))
- const destId = createHmId(input.type, input.eid)
+ const destId = packHmId(hmId(input.type, input.uid))
const correctId = meta?.hmId === destId
const correctVersion =
!input.version || meta?.hmVersion === input.version
@@ -100,7 +100,7 @@ export function useCopyGatewayReference() {
host={gatewayHost}
isPublished={isPublished}
pushingState={pushingState}
- hmId={createHmId(input.type, input.eid)}
+ hmId={packHmId(input)}
/>,
{duration: 8000},
)
@@ -216,7 +216,7 @@ export function PushToGatewayDialog({
onPress={() => {
if (shouldDoAlways) setDoEveryTime('always')
push
- .mutateAsync(createHmId(input.type, input.eid))
+ .mutateAsync(packHmId(input))
.then(() => {
onClose()
toast.success(`Pushed to ${input.host}`)
diff --git a/frontend/apps/desktop/src/components/document-list-item.tsx b/frontend/apps/desktop/src/components/document-list-item.tsx
index 2cb36367..c599ef0c 100644
--- a/frontend/apps/desktop/src/components/document-list-item.tsx
+++ b/frontend/apps/desktop/src/components/document-list-item.tsx
@@ -4,8 +4,9 @@ import {
Document,
HMAccount,
HMDocument,
- createHmId,
getDocumentTitle,
+ hmId,
+ packHmId,
} from '@shm/shared'
import {
ArrowUpRight,
@@ -55,9 +56,11 @@ export const DocumentListItem = React.memo(function DocumentListItem({
const docHmId = docRoute?.id
const docUrl =
docHmId && docRoute
- ? createHmId('d', docHmId.eid, {
- version: docRoute.versionId,
- })
+ ? packHmId(
+ hmId('d', docHmId.uid, {
+ version: docRoute.versionId,
+ }),
+ )
: undefined
const favorite = useFavorite(docUrl)
@@ -89,13 +92,13 @@ export const DocumentListItem = React.memo(function DocumentListItem({
theme="yellow"
zIndex="$zIndex.5"
onPress={(e) => {
- navigate(
- {
- key: 'draft',
- id: hasDraft.id,
- },
- e,
- )
+ // navigate(
+ // {
+ // key: 'draft',
+ // id: hasDraft.id, // todo use unpacked ID here
+ // },
+ // e,
+ // )
}}
size="$1"
>
diff --git a/frontend/apps/desktop/src/components/network-dialog.tsx b/frontend/apps/desktop/src/components/network-dialog.tsx
index c484f3d3..b3ce8f52 100644
--- a/frontend/apps/desktop/src/components/network-dialog.tsx
+++ b/frontend/apps/desktop/src/components/network-dialog.tsx
@@ -151,7 +151,7 @@ const PeerRow = React.memo(function PeerRow({
function handlePress() {
if (isSite && account?.profile?.alias) openUrl(account?.profile?.alias)
else if (!isSite && account?.id)
- spawn({key: 'document', id: hmId('a', account.id)})
+ spawn({key: 'document', id: hmId('d', account.id)})
else toast.error('Could not open account')
}
function handleCopyPeerId() {
diff --git a/frontend/apps/desktop/src/components/publish-draft-button.tsx b/frontend/apps/desktop/src/components/publish-draft-button.tsx
index 76a9ac54..42877820 100644
--- a/frontend/apps/desktop/src/components/publish-draft-button.tsx
+++ b/frontend/apps/desktop/src/components/publish-draft-button.tsx
@@ -5,7 +5,7 @@ import {useNavRoute} from '@/utils/navigation'
import {DraftRoute} from '@/utils/routes'
import {useNavigate} from '@/utils/useNavigate'
import {PlainMessage} from '@bufbuild/protobuf'
-import {Document, hmId, unpackHmId} from '@shm/shared'
+import {Document, hmId, packHmId} from '@shm/shared'
import {
AlertCircle,
Button,
@@ -29,34 +29,38 @@ export default function PublishDraftButton() {
if (!draftRoute)
throw new Error('DraftPublicationButtons requires draft route')
const draftId = draftRoute.id
- const unpackedDraftId = unpackHmId(draftRoute.id)
- const draft = useDraft(draftRoute.id)
- const prevEntity = useEntity(
- unpackedDraftId?.type !== 'draft' ? unpackedDraftId : undefined,
- )
+ const packedDraftId = draftId ? packHmId(draftId) : undefined
+ const draft = useDraft(packedDraftId)
+ const prevEntity = useEntity(draftId?.type !== 'draft' ? draftId : undefined)
const invalidate = useQueryInvalidator()
const deleteDraft = trpc.drafts.delete.useMutation({
onSuccess: () => {
invalidate(['trpc.drafts.get'])
},
})
- const publish = usePublishDraft(grpcClient, draftRoute.id)
+ const publish = usePublishDraft(grpcClient, packedDraftId)
function handlePublish() {
- if (draft.data && unpackedDraftId) {
+ if (draft.data && draftId) {
publish
.mutateAsync({
draft: draft.data,
previous: prevEntity.data?.document as
| PlainMessage
| undefined,
- id: unpackedDraftId.type === 'draft' ? undefined : unpackedDraftId,
+ id: draftId.type === 'draft' ? undefined : draftId,
})
.then(async (res) => {
- const resultDocId = hmId('a', unpackedDraftId.eid)
+ const resultDocId = hmId('d', draftId.uid, {path: draftId.path})
if (draftId)
- await deleteDraft.mutateAsync(draftId).catch((e) => {
- console.error('Failed to delete draft', e)
- })
+ await deleteDraft
+ .mutateAsync(packHmId(draftId))
+ .catch((e) => {
+ console.error('Failed to delete draft', e)
+ })
+ .then(() => {
+ invalidate(['trpc.drafts.get']) // todo, invalidate the specific draft id
+ invalidate(['trpc.drafts.list'])
+ })
if (resultDocId) {
navigate({key: 'document', id: resultDocId})
} else {
diff --git a/frontend/apps/desktop/src/components/sidebar-base.tsx b/frontend/apps/desktop/src/components/sidebar-base.tsx
index 49396c8e..64eea833 100644
--- a/frontend/apps/desktop/src/components/sidebar-base.tsx
+++ b/frontend/apps/desktop/src/components/sidebar-base.tsx
@@ -31,7 +31,6 @@ import {
ArrowDownRight,
ChevronDown,
ChevronRight,
- Contact,
FileText,
Hash,
Search,
@@ -366,7 +365,7 @@ export function MyAccountItem({
appError('Account has not loaded.')
return
}
- onRoute({key: 'document', id: hmId('a', account.id)})
+ onRoute({key: 'document', id: hmId('d', account.id)})
}}
icon={
{
return myAccount
- ? ({key: 'document', id: hmId('a', myAccount)} as DocumentRoute)
+ ? ({key: 'document', id: hmId('d', myAccount)} as DocumentRoute)
: null
}, [myAccount])
const navigate = useNavigate()
@@ -64,8 +56,8 @@ function _SidebarNeo() {
isMyAccountDraftActive ||
(firstEntityRoute &&
firstEntityRoute.key === 'document' &&
- firstEntityRoute.id.type === 'a' &&
- firstEntityRoute.id.eid === myAccount)
+ firstEntityRoute.id.type === 'd' &&
+ firstEntityRoute.id.uid === myAccount)
// const [collapseMe, setCollapseMe] = useState(!isMyAccountActive)
// const entityContents = useRouteEntities(
// myAccountRoute ? [myAccountRoute, ...entityRoutes] : entityRoutes,
@@ -197,12 +189,10 @@ export function getItemDetails(
let icon: IconDefinition | undefined = undefined
let isDraft = false
if (!entity) return null
- console.log(`== ~ entity.id:`, entity.id)
- if (entity.id.type === 'a') {
- name = getProfileName(entity.document)
- icon = Contact
+ if (entity.id.type === 'd') {
+ name = getDocumentTitle(entity.document)
+ icon = FileText
}
-
if (entity.id.type === 'draft') {
name = ''
icon = FilePen
@@ -210,7 +200,6 @@ export function getItemDetails(
}
if (entity.id.path?.[0] != '') {
- console.log('--- ENTITY WITH PATH', entity)
name = getDocumentTitle(entity.document)
icon = FileText
}
@@ -279,7 +268,7 @@ function ContextItems({
{
if (route.key === 'draft') return
@@ -670,19 +659,8 @@ function SidebarFavorites({
if (!collapse) {
items = favorites.map((fav) => {
const {key, url} = fav
- if (key === 'account') {
- return (
-
- )
- }
if (key === 'document') {
- return (
-
- )
+ return
}
return null
})
@@ -719,35 +697,7 @@ function SidebarFavorites({
)
}
-function FavoriteAccountItem({
- url,
- onNavigate,
-}: {
- url: string
- onNavigate: (route: NavRoute) => void
-}) {
- const id = unpackHmId(url)
- const route = useNavRoute()
- const accountId = id?.eid
- const {data} = useEntity(id)
- if (!accountId) return null
- return (
- {
- onNavigate({key: 'document', id: hmId('a', accountId)})
- }}
- title={getProfileName(data?.document)}
- />
- )
-}
-
-function FavoritePublicationItem({
+function FavoriteItem({
url,
onNavigate,
}: {
@@ -757,7 +707,7 @@ function FavoritePublicationItem({
const id = unpackHmId(url)
const route = useNavRoute()
const doc = useEntity(id)
- const documentId = id?.qid
+ const documentId = id?.id
if (!documentId) return null
return (
{
onNavigate({
diff --git a/frontend/apps/desktop/src/components/titlebar-common.tsx b/frontend/apps/desktop/src/components/titlebar-common.tsx
index 3c4aef18..418c0c14 100644
--- a/frontend/apps/desktop/src/components/titlebar-common.tsx
+++ b/frontend/apps/desktop/src/components/titlebar-common.tsx
@@ -22,9 +22,10 @@ import {
BlockRange,
ExpandedBlockRange,
HYPERMEDIA_ENTITY_TYPES,
- createHmId,
createPublicWebHmUrl,
getDocumentTitle,
+ hmId,
+ packHmId,
} from '@shm/shared'
import {
Back,
@@ -107,9 +108,11 @@ export function DocOptionsButton() {
},
]
const docUrl = route.id
- ? createHmId('d', route.id.eid, {
- version: route.id.version,
- })
+ ? packHmId(
+ hmId('d', route.id.uid, {
+ version: route.id.version,
+ }),
+ )
: null
menuItems.push(useFavoriteMenuItem(docUrl))
@@ -129,21 +132,18 @@ function EditDocButton() {
const myAccountIds = useMyAccountIds()
const navigate = useNavigate()
const draft = useDraft(route.id.id)
- if (route.id.type === 'a' && !myAccountIds.data?.includes(route.id.eid)) {
- return null
- }
if (route.tab !== 'home' && route.tab) return null
const hasExistingDraft = !!draft.data
return (
<>
-
+