fix: use url over id as media upload cache key (#1437)

improve-css-focal
Nolan Lawson 2019-08-25 22:24:37 -07:00 zatwierdzone przez GitHub
rodzic e2c137b2ef
commit b46f76fbf8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 4 dodań i 5 usunięć

Wyświetl plik

@ -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 },

Wyświetl plik

@ -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)