Fix LoginWithQR Select Issue

This commit is contained in:
thororen1234 2025-01-25 15:33:39 -05:00
parent 70c42b6043
commit bd8a4b333f

View file

@ -15,6 +15,7 @@ import { preload, unload } from "./images";
import { cl } from "./ui"; import { cl } from "./ui";
import openQrModal from "./ui/modals/QrModal"; import openQrModal from "./ui/modals/QrModal";
const qrModalOpen = false;
export default definePlugin({ export default definePlugin({
name: "LoginWithQR", name: "LoginWithQR",
description: "Allows you to login to another device by scanning a login QR code, just like on mobile!", description: "Allows you to login to another device by scanning a login QR code, just like on mobile!",
@ -46,11 +47,8 @@ export default definePlugin({
{ {
find: ".clipboardData&&(", find: ".clipboardData&&(",
replacement: { replacement: {
// Find the handleGlobalPaste & handlePaste functions and prevent match: /handleGlobalPaste:(\i)/,
// them from firing when the modal is open. Does this have any replace: "handleGlobalPaste:(...args)=>!$self.qrModalOpen&&$1(...args)",
// side effects? Maybe
match: /handle(Global)?Paste:(\i)(}|,)/g,
replace: "handle$1Paste:(...args)=>!$self.qrModalOpen&&$2(...args)$3",
}, },
}, },
// Insert a Scan QR Code button in the My Account tab // Insert a Scan QR Code button in the My Account tab
@ -76,21 +74,21 @@ export default definePlugin({
{ {
find: "useGenerateUserSettingsSections", find: "useGenerateUserSettingsSections",
replacement: { replacement: {
match: /(\.CLIPS)/, match: /\.CONNECTIONS/,
replace: "$1,\"SCAN_QR_CODE\"" replace: "$&,\"SCAN_QR_CODE\""
} }
}, },
// Insert a Scan QR Code button in the Settings sheet (part 2) // Insert a Scan QR Code button in the Settings sheet (part 2)
{ {
find: ".PRIVACY_ENCRYPTION_VERIFIED_DEVICES_V2]", find: ".PRIVACY_ENCRYPTION_VERIFIED_DEVICES_V2]",
replacement: { replacement: {
match: /(\.CLIPS]:{.*?},)/, match: /\.CLIPS]:{.*?},/,
replace: "$1\"SCAN_QR_CODE\":$self.ScanQrSettingsSheet," replace: "$&\"SCAN_QR_CODE\":$self.ScanQrSettingsSheet,"
} }
} }
], ],
qrModalOpen: false, qrModalOpen,
insertScanQrButton: (button: ReactElement) => ( insertScanQrButton: (button: ReactElement) => (
<div className={cl("settings-btns")}> <div className={cl("settings-btns")}>
@ -114,11 +112,10 @@ export default definePlugin({
}, },
start() { start() {
// Preload images
preload(); preload();
}, },
stop() { stop() {
unload?.(); unload();
}, },
}); });