Got stream with default file
This commit is contained in:
@ -32,8 +32,8 @@ import {
|
||||
} from '@tauri-apps/plugin-fs'
|
||||
import makeUrlPathRelative from './lib/makeUrlPathRelative'
|
||||
import {
|
||||
getProjectsInDir,
|
||||
initializeProjectDirectory,
|
||||
isProjectDirectory,
|
||||
PROJECT_ENTRYPOINT,
|
||||
} from './lib/tauriFS'
|
||||
import DownloadAppBanner from './components/DownloadAppBanner'
|
||||
@ -278,15 +278,7 @@ const router = createBrowserRouter(
|
||||
)
|
||||
newDefaultDirectory = projectDir
|
||||
}
|
||||
const projectsNoMeta = (await readDir(projectDir)).filter(
|
||||
isProjectDirectory
|
||||
)
|
||||
const projects = await Promise.all(
|
||||
projectsNoMeta.map(async (p: DirEntry) => ({
|
||||
entrypointMetadata: await stat(p.name + sep() + PROJECT_ENTRYPOINT),
|
||||
...p,
|
||||
}))
|
||||
)
|
||||
const projects = await getProjectsInDir(projectDir)
|
||||
|
||||
return {
|
||||
projects,
|
||||
|
@ -41,6 +41,8 @@ function ProjectCard({
|
||||
function getDisplayedTime(date: Date) {
|
||||
const startOfToday = new Date()
|
||||
startOfToday.setHours(0, 0, 0, 0)
|
||||
// TODO: fix time
|
||||
return ""
|
||||
return date.getTime() < startOfToday.getTime()
|
||||
? date.toLocaleDateString()
|
||||
: date.toLocaleTimeString()
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
writeTextFile,
|
||||
stat,
|
||||
} from '@tauri-apps/plugin-fs'
|
||||
import { documentDir, homeDir, sep } from '@tauri-apps/api/path'
|
||||
import { documentDir, homeDir, join, sep } from '@tauri-apps/api/path'
|
||||
import { isTauri } from './isTauri'
|
||||
import { ProjectWithEntryPointMetadata } from '../Router'
|
||||
|
||||
@ -51,25 +51,19 @@ export async function initializeProjectDirectory(directory: string) {
|
||||
return INITIAL_DEFAULT_DIR
|
||||
}
|
||||
|
||||
export function isProjectDirectory(fileOrDir: Partial<any>) {
|
||||
return (
|
||||
fileOrDir.children?.length &&
|
||||
fileOrDir.children.some((child) => child.name === PROJECT_ENTRYPOINT)
|
||||
)
|
||||
}
|
||||
|
||||
// Read the contents of a directory
|
||||
// and return the valid projects
|
||||
export async function getProjectsInDir(projectDir: string) {
|
||||
const readProjects = (
|
||||
await readDir(projectDir, {
|
||||
recursive: true,
|
||||
})
|
||||
).filter(isProjectDirectory)
|
||||
|
||||
const dirs = await readDir(projectDir)
|
||||
const projectsWithMetadata = await Promise.all(
|
||||
readProjects.map(async (p) => ({
|
||||
entrypointMetadata: await stat(p.name + sep() + PROJECT_ENTRYPOINT),
|
||||
dirs
|
||||
.filter(async (p) => {
|
||||
const files = await readDir(await join(projectDir, p.name))
|
||||
return files.some(d => d.name === PROJECT_ENTRYPOINT)
|
||||
})
|
||||
.map(async (p) => ({
|
||||
entrypointMetadata: await stat(await join(projectDir, p.name, PROJECT_ENTRYPOINT)),
|
||||
path: await join(projectDir, p.name),
|
||||
...p,
|
||||
}))
|
||||
)
|
||||
|
Reference in New Issue
Block a user