From 26b249ad2dd04372aa56103ac59f9ece2eb58f0c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 13 Aug 2019 12:22:33 +0200 Subject: [Glitch] Fix short number formatting for numbers above million in web UI Port 0e9668051e58b2ff4e48b82fa7cc17d385c7a5c9 to glitch-soc Signed-off-by: Thibaut Girka --- app/javascript/flavours/glitch/util/numbers.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/javascript/flavours/glitch/util') diff --git a/app/javascript/flavours/glitch/util/numbers.js b/app/javascript/flavours/glitch/util/numbers.js index fdd8269ae..f7e4ceb93 100644 --- a/app/javascript/flavours/glitch/util/numbers.js +++ b/app/javascript/flavours/glitch/util/numbers.js @@ -4,7 +4,9 @@ import { FormattedNumber } from 'react-intl'; export const shortNumberFormat = number => { if (number < 1000) { return ; - } else { + } else if (number < 1000000) { return K; + } else { + return M; } }; -- cgit From 4e9794f53391b3e8291b800af613bcf6d74550a9 Mon Sep 17 00:00:00 2001 From: ThibG Date: Thu, 15 Aug 2019 11:52:26 +0200 Subject: [Glitch] Fix client-side resizing of image uploads Port f178a01c11a4af077926dd035a0c4c44f6b3985c to glitch-soc Signed-off-by: Thibaut Girka --- app/javascript/flavours/glitch/util/resize_image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript/flavours/glitch/util') diff --git a/app/javascript/flavours/glitch/util/resize_image.js b/app/javascript/flavours/glitch/util/resize_image.js index a8ec5f3fa..d566edb03 100644 --- a/app/javascript/flavours/glitch/util/resize_image.js +++ b/app/javascript/flavours/glitch/util/resize_image.js @@ -71,7 +71,7 @@ const processImage = (img, { width, height, orientation, type = 'image/png' }) = // and return an all-white image instead. Assume reading failed if the resized // image is perfectly white. const imageData = context.getImageData(0, 0, width, height); - if (imageData.every(value => value === 255)) { + if (imageData.data.every(value => value === 255)) { throw 'Failed to read from canvas'; } -- cgit From 5c35c9c40968011ce6b1837bf2c420322b21c83d Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 15 Aug 2019 17:24:45 +0200 Subject: [Glitch] Fix tesseract.js being part of the common chunk Port dfe60598899738250fc707db91048b871ab09282 to glitch-soc Signed-off-by: Thibaut Girka --- .../features/ui/components/focal_point_modal.js | 26 ++++++++++++---------- .../flavours/glitch/util/async-components.js | 4 ++++ 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'app/javascript/flavours/glitch/util') diff --git a/app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js b/app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js index e5a0d029a..6dc47dca3 100644 --- a/app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js +++ b/app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js @@ -10,11 +10,11 @@ import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; import IconButton from 'flavours/glitch/components/icon_button'; import Button from 'flavours/glitch/components/button'; import Video from 'flavours/glitch/features/video'; -import { TesseractWorker } from 'tesseract.js'; import Textarea from 'react-textarea-autosize'; import UploadProgress from 'flavours/glitch/features/compose/components/upload_progress'; import CharacterCounter from 'flavours/glitch/features/compose/components/character_counter'; import { length } from 'stringz'; +import { Tesseract as fetchTesseract } from 'flavours/glitch/util/async-components'; const messages = defineMessages({ close: { id: 'lightbox.close', defaultMessage: 'Close' }, @@ -148,19 +148,21 @@ class FocalPointModal extends ImmutablePureComponent { handleTextDetection = () => { const { media } = this.props; - const worker = new TesseractWorker({ - workerPath: `${assetHost}/packs/ocr/worker.min.js`, - corePath: `${assetHost}/packs/ocr/tesseract-core.wasm.js`, - langPath: `${assetHost}/ocr/lang-data`, - }); - this.setState({ detecting: true }); - worker.recognize(media.get('url')) - .progress(({ progress }) => this.setState({ progress })) - .finally(() => worker.terminate()) - .then(({ text }) => this.setState({ description: removeExtraLineBreaks(text), dirty: true, detecting: false })) - .catch(() => this.setState({ detecting: false })); + fetchTesseract().then(({ TesseractWorker }) => { + const worker = new TesseractWorker({ + workerPath: `${assetHost}/packs/ocr/worker.min.js`, + corePath: `${assetHost}/packs/ocr/tesseract-core.wasm.js`, + langPath: `${assetHost}/ocr/lang-data`, + }); + + worker.recognize(media.get('url')) + .progress(({ progress }) => this.setState({ progress })) + .finally(() => worker.terminate()) + .then(({ text }) => this.setState({ description: removeExtraLineBreaks(text), dirty: true, detecting: false })) + .catch(() => this.setState({ detecting: false })); + }).catch(() => this.setState({ detecting: false })); } render () { diff --git a/app/javascript/flavours/glitch/util/async-components.js b/app/javascript/flavours/glitch/util/async-components.js index f2aeda834..8f2e4c6e4 100644 --- a/app/javascript/flavours/glitch/util/async-components.js +++ b/app/javascript/flavours/glitch/util/async-components.js @@ -153,3 +153,7 @@ export function ListAdder () { export function Search () { return import(/*webpackChunkName: "features/glitch/async/search" */'flavours/glitch/features/search'); } + +export function Tesseract () { + return import(/*webpackChunkName: "tesseract" */'tesseract.js'); +} -- cgit