feat(share): record and display share activity (#549)

* feat(share): record and display share activity

* style(share): remove activity entry borders

* docs(share): explain share link activity
This commit is contained in:
Yiling-J
2026-11-25 12:23:11 +08:00
committed by GitHub
parent 9c8eb16259
commit e32445684f
51 changed files with 3208 additions and 227 deletions
@@ -1,4 +1,5 @@
import { client } from '@/ui/api/client'
import { requestShareDownload } from '@/ui/api/share-download'
import { m } from '@/ui/paraglide/messages.js'
import { Download, AlertCircle } from 'lucide-react'
import React, { useImperativeHandle } from 'react'
@@ -18,10 +19,7 @@ export const DefaultViewer = React.forwardRef<MediaController, FileViewerProps>(
if (!key || !file.id) return
try {
const res = shareId
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
param: { shareId, fileId: file.id },
json: { key },
})
? await requestShareDownload(shareId, file.id, key)
: await client.api.files['download-url'].$post({
json: { key, assetId: file.id },
})
@@ -1,4 +1,5 @@
import { client } from '@/ui/api/client'
import { requestShareDownload } from '@/ui/api/share-download'
import DrawingCanvas from '@/ui/components/drawing-canvas'
import { useScreenSize } from '@/ui/hooks/useScreenSize'
import { getBestTranscode } from '@/ui/lib/media'
@@ -118,10 +119,7 @@ export const CompareImagePane = forwardRef<ComparePaneHandle, CompareImagePanePr
if (!key || !file.id) return
try {
const res = shareId
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
param: { shareId, fileId: file.id },
json: { key },
})
? await requestShareDownload(shareId, file.id, key)
: await client.api.files['download-url'].$post({
json: { key, assetId: file.id },
})
@@ -1,5 +1,6 @@
import { useScreenSize } from '@/ui/hooks/useScreenSize'
import { client } from '@/ui/api/client'
import { requestShareDownload } from '@/ui/api/share-download'
import { getBestTranscode } from '@/ui/lib/media'
import { copyImageToClipboard } from '@/ui/lib/clipboard'
import React, { useEffect, useRef, useState, useImperativeHandle } from 'react'
@@ -106,10 +107,7 @@ export const ImageViewer = React.forwardRef<MediaController, FileViewerProps>(
if (!key || !file.id) return
try {
const res = shareId
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
param: { shareId, fileId: file.id },
json: { key },
})
? await requestShareDownload(shareId, file.id, key)
: await client.api.files['download-url'].$post({
json: { key, assetId: file.id },
})
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useImperativeHandle, useRef, useState }
import { AlertCircle, Loader2 } from 'lucide-react'
import { cn } from '@/ui/lib/utils'
import { client } from '@/ui/api/client'
import { requestShareDownload } from '@/ui/api/share-download'
import DrawingCanvas from '@/ui/components/drawing-canvas'
import { useAnnotationStore } from '@/ui/stores/annotation-store'
import type { FileViewerProps, MediaController } from '../types'
@@ -65,10 +66,7 @@ export const ModelViewer = React.forwardRef<MediaController, FileViewerProps>(
if (!key || !data.id) return
try {
const res = shareId
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
param: { shareId, fileId: data.id },
json: { key },
})
? await requestShareDownload(shareId, data.id, key)
: await client.api.files['download-url'].$post({
json: { key, assetId: data.id },
})
@@ -1,4 +1,5 @@
import { client } from '@/ui/api/client'
import { requestShareDownload } from '@/ui/api/share-download'
import DrawingCanvas from '@/ui/components/drawing-canvas'
import { m } from '@/ui/paraglide/messages.js'
import { useAnnotationStore } from '@/ui/stores/annotation-store'
@@ -383,10 +384,7 @@ export const PdfViewer = React.forwardRef<MediaController, FileViewerProps>(
if (!key || !file.id) return
try {
const res = shareId
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
param: { shareId, fileId: file.id },
json: { key },
})
? await requestShareDownload(shareId, file.id, key)
: await client.api.files['download-url'].$post({
json: { key, assetId: file.id },
})
@@ -1,4 +1,5 @@
import { client } from '@/ui/api/client'
import { requestShareDownload } from '@/ui/api/share-download'
import DrawingCanvas from '@/ui/components/drawing-canvas'
import { cn } from '@/ui/lib/utils'
import { useAnnotationStore } from '@/ui/stores/annotation-store'
@@ -452,10 +453,7 @@ export const CompareVideoPane = forwardRef<ComparePaneHandle, CompareVideoPanePr
if (!dlKey || !file.id) return
try {
const res = shareId
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
param: { shareId, fileId: file.id },
json: { key: dlKey },
})
? await requestShareDownload(shareId, file.id, dlKey)
: await client.api.files['download-url'].$post({
json: { key: dlKey, assetId: file.id },
})
@@ -1,4 +1,5 @@
import { client } from '@/ui/api/client'
import { requestShareDownload } from '@/ui/api/share-download'
import { m } from '@/ui/paraglide/messages.js'
import { cn } from '@/ui/lib/utils'
import { Play, AudioLines, Loader2, AlertCircle } from 'lucide-react'
@@ -901,10 +902,7 @@ const VideoViewer = React.forwardRef<MediaController, FileViewerProps>(
const handleDownload = async (key: string) => {
try {
const res = shareId
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
param: { shareId, fileId: data.id! },
json: { key },
})
? await requestShareDownload(shareId, data.id!, key)
: await client.api.files['download-url'].$post({
json: { key, assetId: data.id! },
})