Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
frontend: update desktop imports
Browse files Browse the repository at this point in the history
  • Loading branch information
horacioh committed Jun 25, 2024
1 parent 887c516 commit ef1fee8
Show file tree
Hide file tree
Showing 117 changed files with 1,251 additions and 1,308 deletions.
4 changes: 2 additions & 2 deletions frontend/apps/desktop/src/app-account.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {DialogTitle} from '@shm/desktop/src/components/dialog'
import {queryKeys} from '@shm/desktop/src/models/query-keys'
import {DialogTitle} from '@/components/dialog'
import {queryKeys} from '@/models/query-keys'
import {eventStream} from '@shm/shared'
import {
Button,
Expand Down
10 changes: 3 additions & 7 deletions frontend/apps/desktop/src/app-api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import {resolveHmIdToAppRoute} from '@shm/desktop/src/utils/navigation'
import {
NavRoute,
defaultRoute,
navRouteSchema,
} from '@shm/desktop/src/utils/routes'
import type {AppWindowEvent} from '@shm/desktop/src/utils/window-events'
import {resolveHmIdToAppRoute} from '@/utils/navigation'
import {NavRoute, defaultRoute, navRouteSchema} from '@/utils/routes'
import type {AppWindowEvent} from '@/utils/window-events'
import {API_GRPC_URL, API_HTTP_URL} from '@shm/shared/src/constants'

import {
Expand Down
2 changes: 1 addition & 1 deletion frontend/apps/desktop/src/app-menu.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// this menu is visible on macOS only
// the keyboard shortcuts apply to every platform

import {defaultRoute} from '@shm/desktop/src/utils/routes'
import {defaultRoute} from '@/utils/routes'
import {Menu, MenuItem} from 'electron'
import {dispatchFocusedWindowAppEvent, openRoute, trpc} from './app-api'

Expand Down
2 changes: 1 addition & 1 deletion frontend/apps/desktop/src/app-recents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NavRoute, getRecentsRouteEntityUrl} from '@shm/desktop/src/utils/routes'
import {NavRoute, getRecentsRouteEntityUrl} from '@/utils/routes'
import {getPublicationVariant} from '@shm/shared'
import {z} from 'zod'
import {grpcClient} from './app-grpc'
Expand Down
10 changes: 5 additions & 5 deletions frontend/apps/desktop/src/app-windows.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import appError from '@shm/desktop/src/errors'
import type {NavState} from '@shm/desktop/src/utils/navigation'
import {NavRoute, defaultRoute} from '@shm/desktop/src/utils/routes'
import type {AppWindowEvent} from '@shm/desktop/src/utils/window-events'
import {getRouteWindowType} from '@shm/desktop/src/utils/window-types'
import appError from '@/errors'
import type {NavState} from '@/utils/navigation'
import {NavRoute, defaultRoute} from '@/utils/routes'
import type {AppWindowEvent} from '@/utils/window-events'
import {getRouteWindowType} from '@/utils/window-types'
import {
BrowserView,
BrowserWindow,
Expand Down
38 changes: 17 additions & 21 deletions frontend/apps/desktop/src/changes-list.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
import { AccessoryContainer } from '@shm/desktop/src/components/accessory-sidebar'
import { AccountLinkAvatar } from '@shm/desktop/src/components/account-link-avatar'
import {
MenuItemType,
OptionsDropdown,
} from '@shm/desktop/src/components/options-dropdown'
import { useAccount } from '@shm/desktop/src/models/accounts'
import { TimelineChange, useDocHistory } from '@shm/desktop/src/models/changes'
import { useGatewayUrl } from '@shm/desktop/src/models/gateway-settings'
import { useOpenUrl } from '@shm/desktop/src/open-url'
import { useNavRoute } from '@shm/desktop/src/utils/navigation'
import { NavRoute } from '@shm/desktop/src/utils/routes'
import { useNavigate } from '@shm/desktop/src/utils/useNavigate'
import {AccessoryContainer} from '@/components/accessory-sidebar'
import {AccountLinkAvatar} from '@/components/account-link-avatar'
import {MenuItemType, OptionsDropdown} from '@/components/options-dropdown'
import {useAccount} from '@/models/accounts'
import {TimelineChange, useDocHistory} from '@/models/changes'
import {useGatewayUrl} from '@/models/gateway-settings'
import {useOpenUrl} from '@/open-url'
import {useNavRoute} from '@/utils/navigation'
import {NavRoute} from '@/utils/routes'
import {useNavigate} from '@/utils/useNavigate'
import {
Change,
createHmId,
createPublicWebHmUrl,
formattedDateLong,
unpackHmId
unpackHmId,
} from '@shm/shared'
import { UnpackedHypermediaId } from '@shm/shared/src/utils/entity-id-url'
import {UnpackedHypermediaId} from '@shm/shared/src/utils/entity-id-url'
import {
ButtonText,
Copy,
SizableText,
Theme,
XStack,
YStack,
copyUrlToClipboardWithFeedback
copyUrlToClipboardWithFeedback,
} from '@shm/ui'
import { ArrowUpRight } from '@tamagui/lucide-icons'
import {ArrowUpRight} from '@tamagui/lucide-icons'

export function EntityVersionsAccessory({
id,
Expand Down Expand Up @@ -87,7 +84,7 @@ function ChangeItem({
const navigate = useNavigate()
const openAccount = (e) => {
e.stopPropagation()
navigate({ key: 'account', accountId: change.author })
navigate({key: 'account', accountId: change.author})
}
const navRoute = useNavRoute()
const isActive = new Set(activeVersion?.split('.') || []).has(change.id)
Expand All @@ -98,8 +95,7 @@ function ChangeItem({
{change.createTime ? formattedDateLong(change.createTime) : null}
</SizableText>
)
const variants =
navRoute.key === 'document' ? navRoute.variants : undefined
const variants = navRoute.key === 'document' ? navRoute.variants : undefined
const topRow = shouldDisplayAuthorName ? (
<XStack paddingTop="$2" gap="$2">
<AccountLinkAvatar accountId={author?.data?.id} size={24} />
Expand All @@ -122,7 +118,7 @@ function ChangeItem({
key: 'document',
documentId: entityId,
versionId: change.id,
accessory: { key: 'versions' },
accessory: {key: 'versions'},
}
}
const parsedEntityId = unpackHmId(entityId)
Expand Down
20 changes: 10 additions & 10 deletions frontend/apps/desktop/src/components/account-link-avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Avatar } from '@shm/desktop/src/components/avatar'
import appError from '@shm/desktop/src/errors'
import { useAccount } from '@shm/desktop/src/models/accounts'
import { useNavigate } from '@shm/desktop/src/utils/useNavigate'
import { Account } from '@shm/shared'
import { Button, FontSizeTokens, Tooltip, YStack } from '@shm/ui'
import { AlertCircle } from '@tamagui/lucide-icons'
import { getAvatarUrl } from '../utils/account-url'
import {Avatar} from '@/components/avatar'
import appError from '@/errors'
import {useAccount} from '@/models/accounts'
import {useNavigate} from '@/utils/useNavigate'
import {Account} from '@shm/shared'
import {Button, FontSizeTokens, Tooltip, YStack} from '@shm/ui'
import {AlertCircle} from '@tamagui/lucide-icons'
import {getAvatarUrl} from '../utils/account-url'

export function ErrorDot() {
return (
Expand Down Expand Up @@ -77,15 +77,15 @@ export function BaseAccountLinkAvatar({
className="no-window-drag"
size="$1"
backgroundColor="transparent"
hoverStyle={{ backgroundColor: 'transparent' }}
hoverStyle={{backgroundColor: 'transparent'}}
minWidth={20}
minHeight={20}
padding={0}
onPress={(e) => {
e.preventDefault()
e.stopPropagation()
if (!accountId) return appError('No account ready to load')
navigate({ key: 'account', accountId })
navigate({key: 'account', accountId})
}}
position="relative"
height={size}
Expand Down
12 changes: 6 additions & 6 deletions frontend/apps/desktop/src/components/app-error.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useSidebarContext } from '@shm/desktop/src/sidebar-context'
import { Button, Heading, SizableText, XStack, YStack, useStream } from '@shm/ui'
import { FallbackProps } from 'react-error-boundary'
import { ErrorBar } from './error-bar'
import {useSidebarContext} from '@/sidebar-context'
import {Button, Heading, SizableText, XStack, YStack, useStream} from '@shm/ui'
import {FallbackProps} from 'react-error-boundary'
import {ErrorBar} from './error-bar'

export function AppErrorPage({ error, resetErrorBoundary }: FallbackProps) {
export function AppErrorPage({error, resetErrorBoundary}: FallbackProps) {
const ctx = useSidebarContext()
const isLocked = useStream(ctx.isLocked)
return (
Expand All @@ -17,7 +17,7 @@ export function AppErrorPage({ error, resetErrorBoundary }: FallbackProps) {
)
}

export function RootAppError({ error, resetErrorBoundary }: FallbackProps) {
export function RootAppError({error, resetErrorBoundary}: FallbackProps) {
return (
<AppErrorContent
message={error.message}
Expand Down
16 changes: 8 additions & 8 deletions frontend/apps/desktop/src/components/avatar-form.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Avatar } from '@shm/desktop/src/components/avatar'
import { useMyAccount } from '@shm/desktop/src/models/accounts'
import { API_FILE_UPLOAD_URL } from '@shm/shared'
import { Stack, Tooltip } from '@shm/ui'
import { ChangeEvent } from 'react'
import {Avatar} from '@/components/avatar'
import {useMyAccount} from '@/models/accounts'
import {API_FILE_UPLOAD_URL} from '@shm/shared'
import {Stack, Tooltip} from '@shm/ui'
import {ChangeEvent} from 'react'
import appError from '../errors'

export function AvatarForm({
Expand All @@ -20,9 +20,9 @@ export function AvatarForm({
const file = fileList?.[0]
if (!file) return
handleUpload(file)
.then(() => { })
.then(() => {})
.catch((error) => {
appError(`Failed to upload avatar: ${e.message}`, { error })
appError(`Failed to upload avatar: ${e.message}`, {error})
})
.finally(() => {
event.target.value = ''
Expand Down Expand Up @@ -54,7 +54,7 @@ export function AvatarForm({
if (disabled) return avatarImage
return (
<Tooltip content="Click or Drag to Set Avatar Image">
<Stack hoverStyle={{ opacity: 0.7 }}>
<Stack hoverStyle={{opacity: 0.7}}>
<input
type="file"
onChange={handleFileChange}
Expand Down
6 changes: 3 additions & 3 deletions frontend/apps/desktop/src/components/citations-context.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEntityMentions } from '@shm/desktop/src/models/content-graph'
import { Mention } from '@shm/shared/src/client/.generated/entities/v1alpha/entities_pb'
import { createContext, ReactNode, useContext, useMemo, useState } from 'react'
import {useEntityMentions} from '@/models/content-graph'
import {Mention} from '@shm/shared/src/client/.generated/entities/v1alpha/entities_pb'
import {createContext, ReactNode, useContext, useMemo, useState} from 'react'

export type CitationsContext = {
citations: Mention[] | undefined
Expand Down
38 changes: 19 additions & 19 deletions frontend/apps/desktop/src/components/citations.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AccessoryContainer } from '@shm/desktop/src/components/accessory-sidebar'
import { AccountLinkAvatar } from '@shm/desktop/src/components/account-link-avatar'
import { useAccount } from '@shm/desktop/src/models/accounts'
import { useComment } from '@shm/desktop/src/models/comments'
import { useEntityMentions } from '@shm/desktop/src/models/content-graph'
import { useDocTextContent, usePublication } from '@shm/desktop/src/models/documents'
import { DocumentRoute } from '@shm/desktop/src/utils/routes'
import { useNavigate } from '@shm/desktop/src/utils/useNavigate'
import {AccessoryContainer} from '@/components/accessory-sidebar'
import {AccountLinkAvatar} from '@/components/account-link-avatar'
import {useAccount} from '@/models/accounts'
import {useComment} from '@/models/comments'
import {useEntityMentions} from '@/models/content-graph'
import {useDocTextContent, usePublication} from '@/models/documents'
import {DocumentRoute} from '@/utils/routes'
import {useNavigate} from '@/utils/useNavigate'
import {
BlockRange,
BlocksContent,
Expand All @@ -16,7 +16,7 @@ import {
serializeBlockRange,
unpackHmId,
} from '@shm/shared'
import { Mention } from '@shm/shared/src/client/.generated/entities/v1alpha/entities_pb'
import {Mention} from '@shm/shared/src/client/.generated/entities/v1alpha/entities_pb'
import {
ButtonText,
PanelCard,
Expand All @@ -25,10 +25,10 @@ import {
YStack,
copyUrlToClipboardWithFeedback,
} from '@shm/ui'
import { useMemo } from 'react'
import { AppPublicationContentProvider } from '../pages/publication-content-provider'
import {useMemo} from 'react'
import {AppPublicationContentProvider} from '../pages/publication-content-provider'

function CitationItem({ mention }: { mention: Mention }) {
function CitationItem({mention}: {mention: Mention}) {
if (!mention.source) throw 'Invalid citation'

if (mention.source.startsWith(`${HYPERMEDIA_SCHEME}://d`)) {
Expand All @@ -42,7 +42,7 @@ function CitationItem({ mention }: { mention: Mention }) {
return null
}

function PublicationCitationItem({ mention }: { mention: Mention }) {
function PublicationCitationItem({mention}: {mention: Mention}) {
const spawn = useNavigate('spawn')
const unpackedSource = unpackHmId(mention.source)
const pub = usePublication(
Expand All @@ -61,7 +61,7 @@ function PublicationCitationItem({ mention }: { mention: Mention }) {
// .filter(([changeId]) => versionChanges.has(changeId))
// .map(([changeId, change]) => change.author),
// )
let { data: account } = useAccount(pub.data?.document?.author)
let {data: account} = useAccount(pub.data?.document?.author)

const docTextContent = useDocTextContent(pub.data)
const destRoute: DocumentRoute = {
Expand Down Expand Up @@ -89,10 +89,10 @@ function PublicationCitationItem({ mention }: { mention: Mention }) {
)
}

function CommentCitationItem({ mention }: { mention: Mention }) {
function CommentCitationItem({mention}: {mention: Mention}) {
const spawn = useNavigate('spawn')
const unpackedSource = unpackHmId(mention.source)
const { data: comment } = useComment(unpackedSource?.id, {
const {data: comment} = useComment(unpackedSource?.id, {
enabled: !!mention.source && !!unpackedSource,
})

Expand All @@ -113,7 +113,7 @@ function CommentCitationItem({ mention }: { mention: Mention }) {
},
)

let { data: account } = useAccount(comment?.author)
let {data: account} = useAccount(comment?.author)

// const docTextContent = useDocTextContent(pub.data)
// const destRoute: DocumentRoute = {
Expand Down Expand Up @@ -226,7 +226,7 @@ function CommentCitationItem({ mention }: { mention: Mention }) {
)
}

export function DocCitationsAccessory({ docId }: { docId?: string }) {
export function DocCitationsAccessory({docId}: {docId?: string}) {
const mentions = useEntityMentions(docId)
if (!docId) return null
const count = mentions.data?.mentions?.length || 0
Expand Down Expand Up @@ -267,7 +267,7 @@ export function DocCitationsAccessory({ docId }: { docId?: string }) {
)
}

export function EntityCitationsAccessory({ entityId }: { entityId?: string }) {
export function EntityCitationsAccessory({entityId}: {entityId?: string}) {
const mentions = useEntityMentions(entityId)
if (!entityId) return null
const count = mentions?.data?.mentions?.length || 0
Expand Down
Loading

0 comments on commit ef1fee8

Please sign in to comment.