From a8998df4b05583253da94f5300955c61da6693b4 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Wed, 25 Oct 2023 19:03:38 +0200 Subject: [PATCH] Also update image fees on blur This makes sure that the images fees reflect the current state. For example, if an image was removed. We could also add debounced requests. --- components/form.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/form.js b/components/form.js index 13ae9c52..1bc901f1 100644 --- a/components/form.js +++ b/components/form.js @@ -270,7 +270,12 @@ export function MarkdownInput ({ label, topLevel, groupClassName, onChange, onKe {...props} onChange={onChangeInner} onKeyDown={onKeyDownInner(userSuggestOnKeyDown)} - onBlur={() => setTimeout(resetSuggestions, 100)} + onBlur={() => { + const text = innerRef?.current.value + const s3Keys = text ? [...text.matchAll(AWS_S3_URL_REGEXP)].map(m => Number(m[1])) : [] + updateImageFees({ variables: { s3Keys } }) + setTimeout(resetSuggestions, 100) + }} />)}