mirror of
https://github.com/get-drexa/drive.git
synced 2025-11-30 21:41:39 +00:00
feat: basic recent file browsing
This commit is contained in:
@@ -188,3 +188,12 @@ export const openFile = authenticatedMutation({
|
||||
return await FileSystem.openFile(ctx, { fileId })
|
||||
},
|
||||
})
|
||||
|
||||
export const fetchRecentFiles = authenticatedQuery({
|
||||
args: {
|
||||
limit: v.number(),
|
||||
},
|
||||
handler: async (ctx, { limit }) => {
|
||||
return await FileSystem.fetchRecentFiles(ctx, { limit })
|
||||
},
|
||||
})
|
||||
|
||||
@@ -265,3 +265,19 @@ export async function openFile(
|
||||
shareToken: newFileShare.shareToken,
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchRecentFiles(
|
||||
ctx: AuthenticatedQueryCtx,
|
||||
{ limit }: { limit: number },
|
||||
) {
|
||||
return await ctx.db
|
||||
.query("files")
|
||||
.withIndex("byLastAccessedAt", (q) =>
|
||||
q
|
||||
.eq("userId", ctx.user._id)
|
||||
.eq("deletedAt", undefined)
|
||||
.gte("lastAccessedAt", 0),
|
||||
)
|
||||
.order("desc")
|
||||
.take(limit)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ const schema = defineSchema({
|
||||
.index("byDirectoryId", ["userId", "directoryId", "deletedAt"])
|
||||
.index("byUserId", ["userId", "deletedAt"])
|
||||
.index("byDeletedAt", ["deletedAt"])
|
||||
.index("byLastAccessedAt", ["userId", "lastAccessedAt"])
|
||||
.index("byLastAccessedAt", ["userId", "deletedAt", "lastAccessedAt"])
|
||||
.index("uniqueFileInDirectory", [
|
||||
"userId",
|
||||
"directoryId",
|
||||
|
||||
Reference in New Issue
Block a user