diff --git a/components/NotesCard.vue b/components/NotesCard.vue index e23e760..9a3b827 100644 --- a/components/NotesCard.vue +++ b/components/NotesCard.vue @@ -124,7 +124,7 @@
- + @@ -141,7 +141,7 @@ > @@ -248,9 +248,9 @@ import CategoryPills from '~/components/CategoryPills.vue' @Component({ components: {DeleteNotesModal, AvatarBar, CategoryPills}, mounted() { - if (this.note.images && this.note.images.length) { + if (this.note.coverImages && this.note.coverImages.length) { this.image = new Image() - this.image.src = this.note.images[0] + this.image.src = this.note.coverImages[0]?.imageURL // this.note.userP this.hasImage = true } @@ -269,6 +269,9 @@ export default class NotesCard extends Vue { deleteNotesOpen = false + get coverImages() { + return this.note.coverImages?.map((img) => img?.imageURL) || [] + } OpenDeleteModal() { this.deleteNotesOpen = true } @@ -292,7 +295,6 @@ export default class NotesCard extends Vue { async toggleLike(id: string, time?: any) { if (this.disabled) return - const a = this.$vs.loading() await notesStore.ToggleLikedNote(id) a.close() diff --git a/mixins/PasteImagesMixin.ts b/mixins/PasteImagesMixin.ts index f64db81..cfdffcc 100644 --- a/mixins/PasteImagesMixin.ts +++ b/mixins/PasteImagesMixin.ts @@ -1,40 +1,19 @@ import {Component, Vue} from 'nuxt-property-decorator' import functions from '~/plugins/firebaseFunctions' import type {StoredImage} from '~/types/firebaseTypes' +import UploadImage from '~/utils/uploadImage' @Component({}) export default class PasteImagesMixin extends Vue { images: StoredImage[] = [] contents!: string async uploadImage(image: File, evt?: any) { - const reader = new FileReader() - const promise = new Promise<{imageURL : string, fileName : string}>((resolve, reject) => { - reader.addEventListener('load', async () => { - const base64image = reader.result - try { - const imageResponse = await functions.httpsCallable( - 'functionPostImage' - )({name: image.name, image: base64image}) - - const imageURL = imageResponse.data.imageURL as string - const fileName = imageResponse.data.fileName as string - if (evt) { - this.insertAtCursor(evt.target, `\n![image](${imageURL})\n`) - } - - this.images.push({ - imageURL, - fileName - }) - return resolve({imageURL, fileName}) - } catch (error) { - console.log({error}) - return reject(error) - } - }) - }) - reader.readAsDataURL(image) - return promise + const imageUpload = await UploadImage(image) + if (evt) { + this.insertAtCursor(evt.target, `\n![image](${imageUpload.imageURL})\n`) + } + this.images.push(imageUpload) + return imageUpload; } async onPaste(evt: any) { diff --git a/screens/notes/PostNotesModal.vue b/screens/notes/PostNotesModal.vue index 388d1ac..3fcb811 100644 --- a/screens/notes/PostNotesModal.vue +++ b/screens/notes/PostNotesModal.vue @@ -47,7 +47,7 @@ class="block mb-3 w-6 mt-3 w-full lg:w-1/2" placeholder="Subject" v-model="subjectSelect" - :disabled="group" + :disabled="!!group" >
@@ -70,7 +70,7 @@ class="block mb-3 w-6 mt-3 w-full lg:w-1/2" placeholder="Grade" v-model="gradeSelect" - :disabled="group" + :disabled="!!group" > + +