diff --git a/src/components/ConversationSettings/ConversationAvatarEditor.vue b/src/components/ConversationSettings/ConversationAvatarEditor.vue
index 2c7f19ffd33..5599a94d18c 100644
--- a/src/components/ConversationSettings/ConversationAvatarEditor.vue
+++ b/src/components/ConversationSettings/ConversationAvatarEditor.vue
@@ -21,7 +21,8 @@
hideUserStatus />
- module.default)
+ return vueCropper
+}
const validMimeTypes = ['image/png', 'image/jpeg']
@@ -140,7 +149,6 @@ export default {
NcColorPicker,
NcEmojiPicker,
NcIconSvgWrapper,
- VueCropper,
// Icons
IconTrashCanOutline,
IconEmoticonOutline,
@@ -187,6 +195,7 @@ export default {
data() {
return {
+ cropperComponent: null,
showCropper: false,
loading: false,
cropperOptions: {
@@ -239,7 +248,14 @@ export default {
methods: {
t,
+
+ async waitForCropper() {
+ this.cropperComponent ??= markRaw(await getCropperAsyncComponent())
+ },
+
activateLocalFilePicker() {
+ // Async request to load and set up component, while user picks the file
+ getCropperAsyncComponent()
// Set to null so that selecting the same file will trigger the change event
this.$refs.input.value = null
this.$refs.input.click()
@@ -255,7 +271,8 @@ export default {
}
const reader = new FileReader()
- reader.onload = (e) => {
+ reader.onload = async (e) => {
+ await this.waitForCropper()
this.$refs.cropper.replace(e.target.result)
this.showCropper = true
}
@@ -263,6 +280,8 @@ export default {
},
async showFilePicker() {
+ // Async request to load and set up component, while user picks the file
+ getCropperAsyncComponent()
const filePicker = getFilePickerBuilder(t('spreed', 'Choose your conversation picture'))
.setContainer('#vue-avatar-section')
.setMultiSelect(false)
@@ -284,6 +303,7 @@ export default {
}
try {
+ await this.waitForCropper()
const tempAvatar = generateUrl(`/core/preview?fileId=${fileid}&x=512&y=512&a=1`)
this.$refs.cropper.replace(tempAvatar)
this.showCropper = true
@@ -325,6 +345,8 @@ export default {
},
async getPictureFormData() {
+ // Cropper should be ready by this moment, so just a safeguard
+ await this.waitForCropper()
const canvasData = this.$refs.cropper.getCroppedCanvas()
const scaleFactor = canvasData.width > 512 ? 512 / canvasData.width : 1