Send avatar/banner media type to server when updating profile info

This commit is contained in:
silverpill 2023-01-07 17:17:18 +00:00
parent 6ff0cf5fb3
commit eb3c8ccce8
3 changed files with 6 additions and 0 deletions

View file

@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Added `/@username` routes for profile pages.
- Allowed to attach image from clipboard.
- Started using media limits provided by the backend.
- Send avatar and banner media types to server when updating profile info.
### Changed

View file

@ -233,7 +233,9 @@ export interface ProfileUpdateData {
display_name: string | null;
note: string | null;
avatar: string | null;
avatar_media_type: string | null;
header: string | null;
header_media_type: string | null;
fields_attributes: ProfileFieldAttrs[];
}

View file

@ -125,7 +125,9 @@ const form = $ref<ProfileUpdateData>({
note: profile.source.note,
fields_attributes: getFieldsAttributes(),
avatar: null,
avatar_media_type: null,
header: null,
header_media_type: null,
})
const images = $ref({
avatar: profile.avatar,
@ -165,6 +167,7 @@ async function onFilePicked(fieldName: "avatar" | "header", event: Event) {
images[fieldName] = imageDataUrl
const imageData = dataUrlToBase64(imageDataUrl)
form[fieldName] = imageData.data
form[`${fieldName}_media_type`] = imageData.mediaType
}
function isValidExtraField(index: number): boolean {