Skip to content

Commit fcf30fa

Browse files
implemented copilot suggestions
1 parent 607f961 commit fcf30fa

File tree

9 files changed

+66
-40
lines changed

9 files changed

+66
-40
lines changed

app/eventyay/webapp/src/components/profile/ChangeAvatar.vue

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -118,54 +118,56 @@ function pixelsRestrictions({ minWidth, minHeight, maxWidth, maxHeight }) {
118118
}
119119
120120
async function update() {
121-
const { canvas } = cropperRef.value?.getResult() || {}
122-
if (!canvas) {
123-
emit('update:modelValue', { identicon: identiconValue.value })
124-
return
125-
}
126-
if (!changedImage.value) return
121+
const { canvas } = cropperRef.value?.getResult() || {}
122+
if (!canvas) {
123+
emit('update:modelValue', { identicon: identiconValue.value })
124+
return
125+
}
126+
if (!changedImage.value) return
127127
128128
const processed = await createAvatarBlob(canvas)
129129
if (!processed) {
130-
fileError.value = 'Failed to process image. Please try a different file.'
131-
emit('blockSave', true)
132-
return
133-
}
130+
fileError.value = proxy.$t('profile/ChangeAvatar:error:process-failed')
131+
emit('blockSave', true)
132+
return
133+
}
134134
const { blob: resizedBlob, dimension } = processed
135-
console.info('[avatar-upload] original size:', selectedFileSize.value || 0, 'bytes; upload size:', resizedBlob.size, 'bytes; dimension:', dimension + 'px')
135+
if (ENV_DEVELOPMENT) {
136+
console.info('[avatar-upload] original size:', selectedFileSize.value || 0, 'bytes; upload size:', resizedBlob.size, 'bytes; dimension:', dimension + 'px')
137+
}
136138
137-
await new Promise((resolve) => {
138-
const request = api.uploadFile(resizedBlob, 'avatar.png', null, dimension, dimension)
139-
const handleFailure = (status, responseText) => {
140-
let message = 'Failed to upload avatar. Please try again.'
141-
if (status === 413) {
142-
message = 'Uploaded image is too large. Please choose a smaller file.'
143-
}
144-
console.error('[avatar-upload]', status, responseText)
145-
fileError.value = message
146-
emit('blockSave', true)
139+
await new Promise((resolve) => {
140+
const request = api.uploadFile(resizedBlob, 'avatar.png', null, dimension, dimension)
141+
const handleFailure = (status, responseText) => {
142+
let message = proxy.$t('profile/ChangeAvatar:error:upload-failed')
143+
if (status === 413) {
144+
message = proxy.$t('profile/ChangeAvatar:error:file-too-large')
145+
}
146+
console.error('[avatar-upload]', status, responseText)
147+
fileError.value = message
148+
emit('blockSave', true)
149+
resolve()
150+
}
151+
request.addEventListener('load', () => {
152+
const status = request.status
153+
const responseText = request.responseText || ''
154+
const contentType = request.getResponseHeader('content-type') || ''
155+
if (status < 200 || status >= 300 || !contentType.includes('application/json')) {
156+
return handleFailure(status, responseText)
157+
}
158+
try {
159+
const response = JSON.parse(responseText)
160+
emit('update:modelValue', { url: response.url })
161+
emit('blockSave', false)
147162
resolve()
163+
} catch (error) {
164+
return handleFailure(status, responseText)
148165
}
149-
request.addEventListener('load', () => {
150-
const status = request.status
151-
const responseText = request.responseText || ''
152-
const contentType = request.getResponseHeader('content-type') || ''
153-
if (status < 200 || status >= 300 || !contentType.includes('application/json')) {
154-
return handleFailure(status, responseText)
155-
}
156-
try {
157-
const response = JSON.parse(responseText)
158-
emit('update:modelValue', { url: response.url })
159-
emit('blockSave', false)
160-
resolve()
161-
} catch (error) {
162-
return handleFailure(status, responseText)
163-
}
164-
})
165-
request.addEventListener('error', () => {
166-
handleFailure(request.status, request.responseText)
167-
})
168166
})
167+
request.addEventListener('error', () => {
168+
handleFailure(request.status, request.responseText)
169+
})
170+
})
169171
}
170172
171173
function createAvatarBlob(sourceCanvas) {

app/eventyay/webapp/src/locales/ar.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@
260260
"profile/ChangeAvatar:or": "أو",
261261
"profile/ChangeAvatar:button-upload:label": "رفع",
262262
"profile/ChangeAvatar:error:image-too-small": "يجب أن يكون حجم الصورة على الأقل 128 بكسل × 128 بكسل.",
263+
"profile/ChangeAvatar:error:process-failed": "تعذر معالجة الصورة. يرجى تجربة ملف آخر.",
264+
"profile/ChangeAvatar:error:upload-failed": "فشل رفع الصورة الرمزية. يرجى المحاولة مرة أخرى.",
265+
"profile/ChangeAvatar:error:file-too-large": "الصورة المرفوعة كبيرة جدًا. يرجى اختيار ملف أصغر.",
263266
"profile/ConnectGravatar:gravatar-connect:label": "اتصال",
264267
"profile/ConnectGravatar:gravatar-email:label": "عنوان البريد الإلكتروني للغرفاتار",
265268
"profile/ConnectGravatar:headline": "إحضار من الغرفاتار",

app/eventyay/webapp/src/locales/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@
258258
"profile/ChangeAvatar:or": "oder",
259259
"profile/ChangeAvatar:button-upload:label": "hochladen",
260260
"profile/ChangeAvatar:error:image-too-small": "Das Bild muss mindestens 128px mal 128px groß sein.",
261+
"profile/ChangeAvatar:error:process-failed": "Bild konnte nicht verarbeitet werden. Bitte versuchen Sie eine andere Datei.",
262+
"profile/ChangeAvatar:error:upload-failed": "Avatar konnte nicht hochgeladen werden. Bitte versuchen Sie es erneut.",
263+
"profile/ChangeAvatar:error:file-too-large": "Das hochgeladene Bild ist zu groß. Bitte wählen Sie eine kleinere Datei.",
261264
"profile/ConnectGravatar:gravatar-connect:label": "Verbinden",
262265
"profile/ConnectGravatar:gravatar-email:label": "Gravatar-E-Mail-Adresse",
263266
"profile/ConnectGravatar:headline": "Von Gravatar abrufen",

app/eventyay/webapp/src/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@
260260
"profile/ChangeAvatar:or": "or",
261261
"profile/ChangeAvatar:button-upload:label": "upload",
262262
"profile/ChangeAvatar:error:image-too-small": "Image must be at least 128px by 128px large.",
263+
"profile/ChangeAvatar:error:process-failed": "Failed to process image. Please try a different file.",
264+
"profile/ChangeAvatar:error:upload-failed": "Failed to upload avatar. Please try again.",
265+
"profile/ChangeAvatar:error:file-too-large": "Uploaded image is too large. Please choose a smaller file.",
263266
"profile/ConnectGravatar:gravatar-connect:label": "Connect",
264267
"profile/ConnectGravatar:gravatar-email:label": "Gravatar email address",
265268
"profile/ConnectGravatar:headline": "Fetch from gravatar",

app/eventyay/webapp/src/locales/es.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@
260260
"profile/ChangeAvatar:or": "o",
261261
"profile/ChangeAvatar:button-upload:label": "subir",
262262
"profile/ChangeAvatar:error:image-too-small": "La imagen debe tener al menos 128px por 128px.",
263+
"profile/ChangeAvatar:error:process-failed": "Error al procesar la imagen. Intenta con otro archivo.",
264+
"profile/ChangeAvatar:error:upload-failed": "No se pudo subir el avatar. Vuelve a intentarlo.",
265+
"profile/ChangeAvatar:error:file-too-large": "La imagen subida es demasiado grande. Elige un archivo más pequeño.",
263266
"profile/ConnectGravatar:gravatar-connect:label": "Conectar",
264267
"profile/ConnectGravatar:gravatar-email:label": "Correo electrónico de Gravatar",
265268
"profile/ConnectGravatar:headline": "Obtener de Gravatar",

app/eventyay/webapp/src/locales/fr.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@
260260
"profile/ChangeAvatar:or": "ou",
261261
"profile/ChangeAvatar:button-upload:label": "télécharger",
262262
"profile/ChangeAvatar:error:image-too-small": "L'image doit mesurer au moins 128px par 128px.",
263+
"profile/ChangeAvatar:error:process-failed": "Échec du traitement de l'image. Veuillez essayer un autre fichier.",
264+
"profile/ChangeAvatar:error:upload-failed": "Échec du téléversement de l'avatar. Veuillez réessayer.",
265+
"profile/ChangeAvatar:error:file-too-large": "L'image téléversée est trop grande. Veuillez choisir un fichier plus petit.",
263266
"profile/ConnectGravatar:gravatar-connect:label": "Connecter",
264267
"profile/ConnectGravatar:gravatar-email:label": "Adresse email Gravatar",
265268
"profile/ConnectGravatar:headline": "Obtenir de Gravatar",

app/eventyay/webapp/src/locales/pt_BR.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@
258258
"profile/ChangeAvatar:or": "ou",
259259
"profile/ChangeAvatar:button-upload:label": "carregar",
260260
"profile/ChangeAvatar:error:image-too-small": "A imagem deve ter pelo menos 128px por 128px.",
261+
"profile/ChangeAvatar:error:process-failed": "Não foi possível processar a imagem. Tente outro arquivo.",
262+
"profile/ChangeAvatar:error:upload-failed": "Não foi possível enviar o avatar. Tente novamente.",
263+
"profile/ChangeAvatar:error:file-too-large": "A imagem enviada é grande demais. Escolha um arquivo menor.",
261264
"profile/ConnectGravatar:gravatar-connect:label": "Conectar",
262265
"profile/ConnectGravatar:gravatar-email:label": "E-mail do Gravatar",
263266
"profile/ConnectGravatar:headline": "Obter do Gravatar",

app/eventyay/webapp/src/locales/ru.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@
260260
"profile/ChangeAvatar:or": "или",
261261
"profile/ChangeAvatar:button-upload:label": "загрузить",
262262
"profile/ChangeAvatar:error:image-too-small": "Изображение должно быть не менее 128 пикселей на 128 пикселей.",
263+
"profile/ChangeAvatar:error:process-failed": "Не удалось обработать изображение. Пожалуйста, попробуйте другой файл.",
264+
"profile/ChangeAvatar:error:upload-failed": "Не удалось загрузить аватар. Повторите попытку.",
265+
"profile/ChangeAvatar:error:file-too-large": "Загруженное изображение слишком большое. Пожалуйста, выберите файл меньшего размера.",
263266
"profile/ConnectGravatar:gravatar-connect:label": "Подключить",
264267
"profile/ConnectGravatar:gravatar-email:label": "Email Gravatar",
265268
"profile/ConnectGravatar:headline": "Получить из Gravatar",

app/eventyay/webapp/src/locales/uk.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@
260260
"profile/ChangeAvatar:or": "або",
261261
"profile/ChangeAvatar:button-upload:label": "завантажити",
262262
"profile/ChangeAvatar:error:image-too-small": "Зображення повинно бути щонайменше 128 пікселів на 128 пікселів.",
263+
"profile/ChangeAvatar:error:process-failed": "Не вдалося обробити зображення. Спробуйте інший файл.",
264+
"profile/ChangeAvatar:error:upload-failed": "Не вдалося завантажити аватар. Спробуйте ще раз.",
265+
"profile/ChangeAvatar:error:file-too-large": "Завантажене зображення занадто велике. Виберіть менший файл.",
263266
"profile/ConnectGravatar:gravatar-connect:label": "Підключити",
264267
"profile/ConnectGravatar:gravatar-email:label": "Email Gravatar",
265268
"profile/ConnectGravatar:headline": "Отримати з Gravatar",

0 commit comments

Comments
 (0)