Skip to content

Commit

Permalink
feat: preview type preferred from searchParam.type (close alist-org/a…
Browse files Browse the repository at this point in the history
  • Loading branch information
potoo0 committed May 23, 2024
1 parent b9e187a commit f851e9e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pages/home/previews/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getIframePreviews } from "~/store"
import { Obj, ObjType } from "~/types"
import { ext } from "~/utils"
import { generateIframePreview } from "./iframe"
import { useRouter } from "~/hooks"

export interface Preview {
name: string
Expand Down Expand Up @@ -88,6 +89,9 @@ const previews: Preview[] = [
export const getPreviews = (
file: Obj & { provider: string },
): PreviewComponent[] => {
const { searchParams } = useRouter()
const typeOverride =
ObjType[searchParams["type"]?.toUpperCase() as keyof typeof ObjType]
const res: PreviewComponent[] = []
// internal previews
previews.forEach((preview) => {
Expand All @@ -96,6 +100,7 @@ export const getPreviews = (
}
if (
preview.type === file.type ||
(typeOverride && preview.type === typeOverride) ||
preview.exts === "*" ||
preview.exts?.includes(ext(file.name).toLowerCase())
) {
Expand Down

0 comments on commit f851e9e

Please sign in to comment.