Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Fix]: Scanner duplicate code, and open URL on success#2042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
raheeliftikhar5 merged 2 commits intolowcoder-org:devfromiamfaran:fix/scanner
Oct 14, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ import React, {
useState,
useContext,
} from "react";
import { arrayStringExposingStateControl } from "comps/controls/codeStateControl";
import { arrayStringExposingStateControl, stringExposingStateControl } from "comps/controls/codeStateControl";
import { BoolControl } from "comps/controls/boolControl";
import { RefControl } from "comps/controls/refControl";
import { EditorContext } from "comps/editorState";
Expand DownExpand Up@@ -120,6 +120,7 @@ const BarcodeScannerComponent = React.lazy(
const ScannerTmpComp = (function () {
const childrenMap = {
data: arrayStringExposingStateControl("data"),
value: stringExposingStateControl("value"),
text: withDefault(StringControl, trans("scanner.text")),
continuous: BoolControl,
uniqueData: withDefault(BoolControl, true),
Expand DownExpand Up@@ -150,17 +151,27 @@ const ScannerTmpComp = (function () {
}, [success, showModal]);

const continuousValue = useRef<string[]>([]);
const seenSetRef = useRef<Set<string>>(new Set());

const handleUpdate = (err: any, result: any) => {
if (result) {
if (props.continuous) {
continuousValue.current = [...continuousValue.current, result.text];
const scannedText: string = result.text;
if (props.uniqueData && seenSetRef.current.has(scannedText)) {
return;
}
continuousValue.current = [...continuousValue.current, scannedText];
if (props.uniqueData) {
seenSetRef.current.add(scannedText);
}
const val = props.uniqueData
? [...new Set(continuousValue.current)]
: continuousValue.current;
props.value.onChange(scannedText);
props.data.onChange(val);
props.onEvent("success");
} else {
props.value.onChange(result.text);
props.data.onChange([result.text]);
setShowModal(false);
setSuccess(true);
Expand DownExpand Up@@ -205,6 +216,7 @@ const ScannerTmpComp = (function () {
props.onEvent("click");
setShowModal(true);
continuousValue.current = [];
seenSetRef.current = new Set();
}}
>
<span>{props.text}</span>
Expand DownExpand Up@@ -317,6 +329,7 @@ const ScannerTmpComp = (function () {

export const ScannerComp = withExposingConfigs(ScannerTmpComp, [
new NameConfig("data", trans("data")),
new NameConfig("value", trans("value")),
new NameConfig("text", trans("button.textDesc")),
...CommonNameConfig,
]);
Loading

[8]ページ先頭

©2009-2025 Movatter.jp