Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
1dd25634
Unverified
Commit
1dd25634
authored
Aug 10, 2025
by
Jason Shawn D' Souza
Committed by
GitHub
Aug 10, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Midi files show up as playable (#4991)
parent
6b507ff6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
MemoAttachment.tsx
web/src/components/MemoAttachment.tsx
+2
-2
attachment.ts
web/src/utils/attachment.ts
+6
-1
No files found.
web/src/components/MemoAttachment.tsx
View file @
1dd25634
import
{
Attachment
}
from
"@/types/proto/api/v1/attachment_service"
;
import
{
Attachment
}
from
"@/types/proto/api/v1/attachment_service"
;
import
{
getAttachmentUrl
}
from
"@/utils/attachment"
;
import
{
getAttachmentUrl
,
isMidiFile
}
from
"@/utils/attachment"
;
import
AttachmentIcon
from
"./AttachmentIcon"
;
import
AttachmentIcon
from
"./AttachmentIcon"
;
interface
Props
{
interface
Props
{
...
@@ -19,7 +19,7 @@ const MemoAttachment: React.FC<Props> = (props: Props) => {
...
@@ -19,7 +19,7 @@ const MemoAttachment: React.FC<Props> = (props: Props) => {
<
div
<
div
className=
{
`w-auto flex flex-row justify-start items-center text-muted-foreground hover:text-foreground hover:bg-accent rounded px-2 py-1 transition-colors ${className}`
}
className=
{
`w-auto flex flex-row justify-start items-center text-muted-foreground hover:text-foreground hover:bg-accent rounded px-2 py-1 transition-colors ${className}`
}
>
>
{
attachment
.
type
.
startsWith
(
"audio"
)
?
(
{
attachment
.
type
.
startsWith
(
"audio"
)
&&
!
isMidiFile
(
attachment
.
type
)
?
(
<
audio
src=
{
attachmentUrl
}
controls
></
audio
>
<
audio
src=
{
attachmentUrl
}
controls
></
audio
>
)
:
(
)
:
(
<>
<>
...
...
web/src/utils/attachment.ts
View file @
1dd25634
...
@@ -13,7 +13,7 @@ export const getAttachmentType = (attachment: Attachment) => {
...
@@ -13,7 +13,7 @@ export const getAttachmentType = (attachment: Attachment) => {
return
"image/*"
;
return
"image/*"
;
}
else
if
(
attachment
.
type
.
startsWith
(
"video"
))
{
}
else
if
(
attachment
.
type
.
startsWith
(
"video"
))
{
return
"video/*"
;
return
"video/*"
;
}
else
if
(
attachment
.
type
.
startsWith
(
"audio"
))
{
}
else
if
(
attachment
.
type
.
startsWith
(
"audio"
)
&&
!
isMidiFile
(
attachment
.
type
)
)
{
return
"audio/*"
;
return
"audio/*"
;
}
else
if
(
attachment
.
type
.
startsWith
(
"text"
))
{
}
else
if
(
attachment
.
type
.
startsWith
(
"text"
))
{
return
"text/*"
;
return
"text/*"
;
...
@@ -40,6 +40,11 @@ export const isImage = (t: string) => {
...
@@ -40,6 +40,11 @@ export const isImage = (t: string) => {
return
t
.
startsWith
(
"image/"
)
&&
!
isPSD
(
t
);
return
t
.
startsWith
(
"image/"
)
&&
!
isPSD
(
t
);
};
};
// isMidiFile returns true if the given mime type is a MIDI file.
export
const
isMidiFile
=
(
mimeType
:
string
):
boolean
=>
{
return
mimeType
===
"audio/midi"
||
mimeType
===
"audio/mid"
||
mimeType
===
"audio/x-midi"
||
mimeType
===
"application/x-midi"
;
};
const
isPSD
=
(
t
:
string
)
=>
{
const
isPSD
=
(
t
:
string
)
=>
{
return
t
===
"image/vnd.adobe.photoshop"
||
t
===
"image/x-photoshop"
||
t
===
"image/photoshop"
;
return
t
===
"image/vnd.adobe.photoshop"
||
t
===
"image/x-photoshop"
||
t
===
"image/photoshop"
;
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment