Compare commits

..
2 changed files with 14 additions and 74 deletions

No files matched your search

-45
View File
@@ -1,45 +0,0 @@
import type { MenuComponentProps } from "@expo/ui/community/menu"
import { Button, Host, Menu, RNHostView } from "@expo/ui/swift-ui"
import { disabled, menuOrder } from "@expo/ui/swift-ui/modifiers"
// SwiftUI's automatic order reverses menus that open upward in the player.
// Keep the same top-to-bottom order as the UIKit long-press menus.
export function MenuView({
actions,
children,
style,
testID,
onPressAction,
}: MenuComponentProps) {
return (
<Host matchContents style={style} testID={testID} ignoreSafeArea="all">
<Menu
modifiers={[menuOrder("fixed")]}
label={
<RNHostView matchContents>
<>{children}</>
</RNHostView>
}
>
{actions
.filter((action) => !action.attributes?.hidden)
.map((action) => (
<Button
key={action.id ?? action.title}
label={action.title}
systemImage={
typeof action.image === "string" ? action.image : undefined
}
role={action.attributes?.destructive ? "destructive" : undefined}
modifiers={[disabled(action.attributes?.disabled ?? false)]}
onPress={() =>
onPressAction?.({
nativeEvent: { event: action.id ?? action.title },
})
}
/>
))}
</Menu>
</Host>
)
}
+14 -29
View File
@@ -68,21 +68,6 @@ async function coverPathIfExists(path: string): Promise<string | null> {
.catch(() => null)
}
async function shouldReplaceCover(dbCover: string | null) {
return dbCover === null || (await coverPathIfExists(dbCover)) === null
}
function isCodecPath(filePath: string, codec: string) {
return filePath.startsWith(`${DATA_DIR}/${codec}/`)
}
function releaseDate(common: music.ICommonTagsResult) {
if (common.date) {
return common.date
}
return common.year ? `01-01-${common.year}` : ""
}
async function syncArtistCover(
ctx: ActionCtx,
codec: string,
@@ -92,13 +77,13 @@ async function syncArtistCover(
) {
const onDisk = await coverPathIfExists(diskPath)
if (onDisk !== null) {
if (await shouldReplaceCover(dbCover)) {
if (dbCover !== onDisk) {
await ctx.runMutation(internal.library.updateArtistCover, {
id,
cover: onDisk,
})
}
} else if (dbCover !== null && isCodecPath(dbCover, codec)) {
} else if (dbCover !== null && dbCover.includes(codec)) {
await ctx.runMutation(internal.library.updateArtistCover, {
id,
cover: null,
@@ -115,13 +100,13 @@ async function syncAlbumCover(
) {
const onDisk = await coverPathIfExists(diskPath)
if (onDisk !== null) {
if (await shouldReplaceCover(dbCover)) {
if (dbCover !== onDisk) {
await ctx.runMutation(internal.library.updateAlbumCover, {
id,
cover: onDisk,
})
}
} else if (dbCover !== null && isCodecPath(dbCover, codec)) {
} else if (dbCover !== null && dbCover.includes(codec)) {
await ctx.runMutation(internal.library.updateAlbumCover, {
id,
cover: null,
@@ -417,8 +402,9 @@ export const scheduledUpdateLibrary = internalAction({
name: metadata.common.album || potentialAlbum,
folder: potentialAlbum,
cover,
year: metadata.common.year || 0,
date: releaseDate(metadata.common),
year: metadata.common.year || 2026,
date:
metadata.common.date || `01-01-${metadata.common.year || 2026}`,
artist: dbArtist._id,
})
} catch {}
@@ -508,14 +494,11 @@ export const scheduledUpdateLibrary = internalAction({
)
if (existingSong) {
// A tracked path that still exists is a different file with the
// same title; replacing it would flip-flop between scans.
const trackedPath = existingSong.files[codec]
if (
trackedPath === undefined ||
!fsSync.existsSync(trackedPath)
!(codec in existingSong.files) ||
existingSong.files[codec] !== path
) {
const update = { ...existingSong.files, [codec]: path }
const update = { [codec]: path, ...existingSong.files }
updateSongs.push({
id: existingSong._id,
files: update,
@@ -567,8 +550,10 @@ export const scheduledUpdateLibrary = internalAction({
? null
: metadata.common.disk.no,
track: metadata.common.track.no || 0,
year: metadata.common.year || 0,
date: releaseDate(metadata.common),
year: metadata.common.year || 2026,
date:
metadata.common.date ||
`01-01-${metadata.common.year || 2026}`,
genres: metadata.common.genre || [],
})
}