From 77be17dcce5c9df8dbf800f7e9318f8319db9239 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 6 Oct 2024 13:42:21 -0400 Subject: [PATCH] Update LoginWithQR --- src/equicordplugins/loginWithQR/images.ts | 6 +- src/equicordplugins/loginWithQR/index.tsx | 76 ++++++++++--------- src/equicordplugins/loginWithQR/ui/index.ts | 1 - .../loginWithQR/ui/modals/QrModal.tsx | 26 ++++++- src/equicordplugins/loginWithQR/ui/styles.css | 29 +++++-- 5 files changed, 87 insertions(+), 51 deletions(-) diff --git a/src/equicordplugins/loginWithQR/images.ts b/src/equicordplugins/loginWithQR/images.ts index c73d3e98..865ea50a 100644 --- a/src/equicordplugins/loginWithQR/images.ts +++ b/src/equicordplugins/loginWithQR/images.ts @@ -8,11 +8,11 @@ export const images = { cross: "https://i.imgur.com/XxRnu3b.png", deviceImage: { success: - "https://github.com/nexpid/Themelings/blob/3a063c5188f4cac096171f29163f9e2659f275a3/icons/images/native/img_remote_auth_succeeded.png", + "https://github.com/nexpid/Themelings/raw/data/icons/images/native/img_remote_auth_succeeded.png", notFound: - "https://github.com/nexpid/Themelings/blob/3a063c5188f4cac096171f29163f9e2659f275a3/icons/images/native/img_remote_auth_not_found.png", + "https://github.com/nexpid/Themelings/raw/data/icons/images/native/img_remote_auth_not_found.png", loading: - "https://github.com/nexpid/Themelings/blob/3a063c5188f4cac096171f29163f9e2659f275a3/icons/images/native/img_remote_auth_loaded.png", + "https://github.com/nexpid/Themelings/raw/data/icons/images/native/img_remote_auth_loaded.png", }, } as const; diff --git a/src/equicordplugins/loginWithQR/index.tsx b/src/equicordplugins/loginWithQR/index.tsx index 394165ac..bd2653b6 100644 --- a/src/equicordplugins/loginWithQR/index.tsx +++ b/src/equicordplugins/loginWithQR/index.tsx @@ -5,19 +5,25 @@ */ import { definePluginSettings } from "@api/Settings"; -import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { Button, Forms, i18n, Menu, TabBar } from "@webpack/common"; +import { Button, Forms, i18n, Menu } from "@webpack/common"; import { ReactElement } from "react"; import { preload, unload } from "./images"; -import { cl, QrCodeIcon } from "./ui"; +import { cl } from "./ui"; import openQrModal from "./ui/modals/QrModal"; export default definePlugin({ name: "LoginWithQR", - description: "Allows you to login to another device by scanning a login QR code, just like on mobile!", - authors: [EquicordDevs.nexpid], + description: + "Allows you to login to another device by scanning a login QR code, just like on mobile!", + // replace with EquicordDevs.nexpid when merged to Equicord + authors: [ + { + name: "Nexpid", + id: 853550207039832084n, + }, + ], settings: definePluginSettings({ scanQr: { @@ -62,25 +68,31 @@ export default definePlugin({ replace: ",$self.insertScanQrButton($1)", }, }, - // Insert a Scan QR Code MenuItem in the simplified user popout + // Insert a Scan QR Code MenuItem in the Swith Accounts popout { - find: "Messages.MULTI_ACCOUNT_MENU_LABEL", + find: ".SWITCH_ACCOUNTS_MANAGE_ACCOUNTS,", replacement: { - // Insert our own MenuItem before the Switch Accounts button - match: /children:\[(.{0,54}id:"switch-accounts")/, - replace: "children:[$self.ScanQrMenuItem,$1", - }, + match: /(id:"manage-accounts",.*?)}\)\)(,\i)/, + replace: "$1}),$self.ScanQrMenuItem)$2" + } }, - // Add a Scan QR entry to the settings TabBar + + // Insert a Scan QR Code button in the Settings sheet { - find: ".BILLING_SETTINGS,", + find: "useGenerateUserSettingsSections", replacement: { - match: /((\i\.settings)\.forEach.+?(\i).push\(.+}\)}\))/, - replace: (_, original, settings, elements) => - `${original},${settings}?.[0]=="ACCOUNT"` + - `&&${elements}.push({section:"CUSTOM",element:$self.ScanQrTabBarComponent})`, - }, + match: /(\.FRIEND_REQUESTS)/, + replace: "$1,\"SCAN_QR_CODE\"" + } }, + // Insert a Scan QR Code button in the Settings sheet (part 2) + { + find: ".PRIVACY_ENCRYPTION_VERIFIED_DEVICES_V2]", + replacement: { + match: /(\.CLIPS]:{.*?},)/, + replace: "$1\"SCAN_QR_CODE\":$self.ScanQrSettingsSheet," + } + } ], qrModalOpen: false, @@ -93,26 +105,18 @@ export default definePlugin({ {button} ), - get ScanQrMenuItem() { - return ( -