From b46f76fbf80a86eea210873f30cf9abee7f8ecd2 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 25 Aug 2019 22:24:37 -0700 Subject: [PATCH] fix: use url over id as media upload cache key (#1437) --- src/routes/_actions/media.js | 2 +- .../_components/dialog/components/MediaAltEditor.html | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/routes/_actions/media.js b/src/routes/_actions/media.js index 25d5ae23..d71f43fa 100644 --- a/src/routes/_actions/media.js +++ b/src/routes/_actions/media.js @@ -13,7 +13,7 @@ export async function doMediaUpload (realm, file) { if (composeMedia.length === 4) { throw new Error('Only 4 media max are allowed') } - mediaUploadFileCache.set(response.id, file) + mediaUploadFileCache.set(response.url, file) composeMedia.push({ data: response, file: { name: file.name }, diff --git a/src/routes/_components/dialog/components/MediaAltEditor.html b/src/routes/_components/dialog/components/MediaAltEditor.html index a2dd00a1..2062b096 100644 --- a/src/routes/_components/dialog/components/MediaAltEditor.html +++ b/src/routes/_components/dialog/components/MediaAltEditor.html @@ -120,8 +120,7 @@ computed: { length: ({ rawText }) => length(rawText || ''), overLimit: ({ mediaAltCharLimit, length }) => length > mediaAltCharLimit, - url: ({ media, index }) => get(media, [index, 'data', 'url']), - mediaId: ({ media, index }) => get(media, [index, 'data', 'id']) + url: ({ media, index }) => get(media, [index, 'data', 'url']) }, methods: { observe, @@ -167,8 +166,8 @@ async onClick () { this.set({ extracting: true }) try { - const { url, mediaId } = this.get() - const file = mediaUploadFileCache.get(mediaId) + const { url } = this.get() + const file = mediaUploadFileCache.get(url) let text if (file) { // Avoid downloading from the network a file that the user *just* uploaded const fileUrl = URL.createObjectURL(file)