fix: use url over id as media upload cache key (#1437)
This commit is contained in:
parent
e2c137b2ef
commit
b46f76fbf8
2 changed files with 4 additions and 5 deletions
|
@ -13,7 +13,7 @@ export async function doMediaUpload (realm, file) {
|
||||||
if (composeMedia.length === 4) {
|
if (composeMedia.length === 4) {
|
||||||
throw new Error('Only 4 media max are allowed')
|
throw new Error('Only 4 media max are allowed')
|
||||||
}
|
}
|
||||||
mediaUploadFileCache.set(response.id, file)
|
mediaUploadFileCache.set(response.url, file)
|
||||||
composeMedia.push({
|
composeMedia.push({
|
||||||
data: response,
|
data: response,
|
||||||
file: { name: file.name },
|
file: { name: file.name },
|
||||||
|
|
|
@ -120,8 +120,7 @@
|
||||||
computed: {
|
computed: {
|
||||||
length: ({ rawText }) => length(rawText || ''),
|
length: ({ rawText }) => length(rawText || ''),
|
||||||
overLimit: ({ mediaAltCharLimit, length }) => length > mediaAltCharLimit,
|
overLimit: ({ mediaAltCharLimit, length }) => length > mediaAltCharLimit,
|
||||||
url: ({ media, index }) => get(media, [index, 'data', 'url']),
|
url: ({ media, index }) => get(media, [index, 'data', 'url'])
|
||||||
mediaId: ({ media, index }) => get(media, [index, 'data', 'id'])
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
observe,
|
observe,
|
||||||
|
@ -167,8 +166,8 @@
|
||||||
async onClick () {
|
async onClick () {
|
||||||
this.set({ extracting: true })
|
this.set({ extracting: true })
|
||||||
try {
|
try {
|
||||||
const { url, mediaId } = this.get()
|
const { url } = this.get()
|
||||||
const file = mediaUploadFileCache.get(mediaId)
|
const file = mediaUploadFileCache.get(url)
|
||||||
let text
|
let text
|
||||||
if (file) { // Avoid downloading from the network a file that the user *just* uploaded
|
if (file) { // Avoid downloading from the network a file that the user *just* uploaded
|
||||||
const fileUrl = URL.createObjectURL(file)
|
const fileUrl = URL.createObjectURL(file)
|
||||||
|
|
Loading…
Add table
Reference in a new issue