A decentralized music tracking and discovery platform built on AT Protocol 🎵

[api] return parent directory

+74 -13
+8 -1
apps/api/src/xrpc/app/rocksky/dropbox/getFiles.ts
··· 45 45 }) => { 46 46 return Effect.tryPromise({ 47 47 try: async () => { 48 + const parentDirAlias = alias(tables.dropboxDirectories, "parent_dir"); 48 49 const parentAlias = alias(tables.dropboxDirectories, "parent"); 49 50 return Promise.all([ 50 51 ctx.db ··· 59 60 parentAlias, 60 61 eq(parentAlias.id, tables.dropboxDirectories.parentId) 61 62 ) 63 + .leftJoin(parentDirAlias, eq(parentDirAlias.id, parentAlias.parentId)) 62 64 .where( 63 65 and( 64 66 eq(tables.users.did, did), ··· 80 82 parentAlias, 81 83 eq(parentAlias.id, tables.dropboxPaths.directoryId) 82 84 ) 85 + .leftJoin(parentDirAlias, eq(parentDirAlias.id, parentAlias.parentId)) 83 86 .leftJoin( 84 87 tables.dropbox, 85 88 eq(tables.dropbox.id, tables.dropboxPaths.dropboxId) ··· 110 113 111 114 const presentation = (data) => { 112 115 return Effect.sync(() => ({ 113 - parentDirectory: R.omit( 116 + directory: R.omit( 114 117 ["createdAt", "updatedAt", "xataVersion"], 115 118 _.get(data, "0.0.parent", null) || _.get(data, "1.0.parent", null) 119 + ), 120 + parentDirectory: R.omit( 121 + ["createdAt", "updatedAt"], 122 + _.get(data, "0.0.parent_dir", null) || _.get(data, "1.0.parent_dir", null) 116 123 ), 117 124 directories: data[0].map((item) => ({ 118 125 id: item.dropbox_directories.id,
+8 -1
apps/api/src/xrpc/app/rocksky/googledrive/getFiles.ts
··· 44 44 }) => { 45 45 return Effect.tryPromise({ 46 46 try: async () => { 47 + const parentDirAlias = alias(tables.googleDriveDirectories, "parent_dir"); 47 48 const parentAlias = alias(tables.googleDriveDirectories, "parent"); 48 49 return Promise.all([ 49 50 ctx.db ··· 64 65 parentAlias, 65 66 eq(parentAlias.id, tables.googleDriveDirectories.parentId) 66 67 ) 68 + .leftJoin(parentDirAlias, eq(parentDirAlias.id, parentAlias.parentId)) 67 69 .where( 68 70 and( 69 71 eq(tables.users.did, did), ··· 85 87 parentAlias, 86 88 eq(tables.googleDrivePaths.directoryId, parentAlias.id) 87 89 ) 90 + .leftJoin(parentDirAlias, eq(parentDirAlias.id, parentAlias.parentId)) 88 91 .leftJoin( 89 92 tables.googleDrive, 90 93 eq(tables.googleDrive.id, tables.googleDrivePaths.googleDriveId) ··· 118 121 119 122 const presentation = (data) => { 120 123 return Effect.sync(() => ({ 121 - parentDirectory: R.omit( 124 + directory: R.omit( 122 125 ["createdAt", "updatedAt", "xataVersion"], 123 126 _.get(data, "0.0.parent", null) || _.get(data, "1.0.parent", null) 127 + ), 128 + parentDirectory: R.omit( 129 + ["createdAt", "updatedAt"], 130 + _.get(data, "0.0.parent_dir", null) || _.get(data, "1.0.parent_dir", null) 124 131 ), 125 132 directories: data[0].map((item) => ({ 126 133 id: item.google_drive_directories.id,
+6
apps/web/src/api/dropbox.ts
··· 4 4 5 5 export const getFiles = async (id?: string) => { 6 6 const response = await client.get<{ 7 + parentDirectory: { 8 + id: string; 9 + name: string; 10 + path: string; 11 + fileId: string; 12 + }; 7 13 directories: { 8 14 id: string; 9 15 name: string;
+6
apps/web/src/api/googledrive.ts
··· 2 2 3 3 export const getFiles = async (parent_id?: string) => { 4 4 const response = await client.get<{ 5 + parentDirectory: { 6 + id: string; 7 + name: string; 8 + path: string; 9 + fileId: string; 10 + }; 5 11 directories: { 6 12 id: string; 7 13 name: string;
+23 -6
apps/web/src/pages/dropbox/Dropbox.tsx
··· 1 1 /* eslint-disable @typescript-eslint/no-explicit-any */ 2 2 import { Folder2, MusicNoteBeamed } from "@styled-icons/bootstrap"; 3 + import { Link } from "@tanstack/react-router"; 3 4 import { createColumnHelper } from "@tanstack/react-table"; 5 + import { Breadcrumbs } from "baseui/breadcrumbs"; 4 6 import { HeadingMedium } from "baseui/typography"; 5 7 import ContentLoader from "react-content-loader"; 6 8 import Table from "../../components/Table"; ··· 17 19 18 20 const Dropbox = (props: DropboxProps) => { 19 21 const { data, isLoading } = useFilesQuery(props.fileId); 22 + const { data: parent } = useFilesQuery(data?.parentDirectory?.fileId); 20 23 21 24 const playFile = async (id: string) => { 22 25 console.log(">> Playing file:", id); ··· 66 69 ), 67 70 }), 68 71 ]; 69 - 70 - const current_dir = "Dropbox"; 71 72 72 73 /* 73 74 useEffect(() => { ··· 150 151 ) 151 152 */} 152 153 <div className="pt-[80px] fixed bg-[var(--color-background)] top-[19px] w-[770px]"> 154 + <Breadcrumbs> 155 + { 156 + <Link 157 + to={ 158 + parent?.parentDirectory?.path === "/Music" 159 + ? `/dropbox` 160 + : `/dropbox/$id` 161 + } 162 + params={{ id: parent?.parentDirectory?.fileId || "" }} 163 + className="!text-[var(--color-text)]" 164 + > 165 + {parent?.parentDirectory?.path === "/Music" 166 + ? "" 167 + : parent?.parentDirectory?.name} 168 + </Link> 169 + } 170 + </Breadcrumbs> 153 171 <HeadingMedium 154 172 marginTop={"10px"} 155 173 marginBottom={"25px"} 156 174 className="!text-[var(--color-text)]" 157 175 > 158 - { 159 - //current_dir === "Music" ? "Dropbox" : current_dir 160 - current_dir 161 - } 176 + {data?.parentDirectory?.path === "/Music" 177 + ? "Dropbox" 178 + : data?.parentDirectory?.name} 162 179 </HeadingMedium> 163 180 </div> 164 181
+23 -5
apps/web/src/pages/googledrive/GoogleDrive.tsx
··· 1 1 /* eslint-disable @typescript-eslint/no-explicit-any */ 2 2 import { Folder2, MusicNoteBeamed } from "@styled-icons/bootstrap"; 3 + import { Link } from "@tanstack/react-router"; 3 4 import { createColumnHelper } from "@tanstack/react-table"; 5 + import { Breadcrumbs } from "baseui/breadcrumbs"; 4 6 import { HeadingMedium } from "baseui/typography"; 5 7 import ContentLoader from "react-content-loader"; 6 8 import Table from "../../components/Table"; ··· 17 19 18 20 const GoogleDrive = (props: GoogleDriveProps) => { 19 21 const { data, isLoading } = useFilesQuery(props.fileId); 22 + const { data: parent } = useFilesQuery(data?.parentDirectory?.fileId); 20 23 21 24 const columns = [ 22 25 columnHelper.accessor("name", { ··· 112 115 // eslint-disable-next-line react-hooks/exhaustive-deps 113 116 }, [props.fileId]); 114 117 */ 115 - const current_dir = "Google Drive"; 116 118 117 119 return ( 118 120 <Main> ··· 144 146 </div> 145 147 )*/} 146 148 <div className="pt-[80px] fixed bg-[var(--color-background)] top-[19px] w-[770px]"> 149 + <Breadcrumbs> 150 + { 151 + <Link 152 + to={ 153 + parent?.parentDirectory?.path === "/Music" 154 + ? `/googledrive` 155 + : `/googledrive/$id` 156 + } 157 + params={{ id: parent?.parentDirectory?.fileId || "" }} 158 + className="!text-[var(--color-text)]" 159 + > 160 + {parent?.parentDirectory?.path === "/Music" 161 + ? "" 162 + : parent?.parentDirectory?.name} 163 + </Link> 164 + } 165 + </Breadcrumbs> 147 166 <HeadingMedium 148 167 marginTop={"10px"} 149 168 marginBottom={"25px"} 150 169 className="!text-[var(--color-text)]" 151 170 > 152 - { 153 - //current_dir === "Music" ? "Google Drive" : current_dir 154 - current_dir 155 - } 171 + {data?.parentDirectory?.path === "/Music" 172 + ? "Google Drive" 173 + : data?.parentDirectory?.name} 156 174 </HeadingMedium> 157 175 </div> 158 176