mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-19 11:27:02 -04:00
Update LoginWithQR
This commit is contained in:
parent
94831de711
commit
77be17dcce
5 changed files with 87 additions and 51 deletions
|
@ -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}
|
||||
</div>
|
||||
),
|
||||
|
||||
get ScanQrMenuItem() {
|
||||
return (
|
||||
<Menu.MenuGroup>
|
||||
<Menu.MenuItem
|
||||
id="scan-qr"
|
||||
label={i18n.Messages.USER_SETTINGS_SCAN_QR_CODE}
|
||||
icon={QrCodeIcon}
|
||||
action={openQrModal}
|
||||
showIconFirst
|
||||
/>
|
||||
</Menu.MenuGroup>
|
||||
);
|
||||
return <Menu.MenuItem id="scan-qr" label={i18n.Messages.USER_SETTINGS_SCAN_QR_CODE} action={openQrModal} />;
|
||||
},
|
||||
get ScanQrSettingsSheet() {
|
||||
return {
|
||||
section: i18n.Messages.USER_SETTINGS_SCAN_QR_CODE,
|
||||
onClick: openQrModal,
|
||||
searchableTitles: [i18n.Messages.USER_SETTINGS_SCAN_QR_CODE],
|
||||
label: i18n.Messages.USER_SETTINGS_SCAN_QR_CODE,
|
||||
ariaLabel: i18n.Messages.USER_SETTINGS_SCAN_QR_CODE
|
||||
};
|
||||
},
|
||||
|
||||
ScanQrTabBarComponent: () => (
|
||||
<TabBar.Item id="Scan QR Code" onClick={openQrModal}>
|
||||
{i18n.Messages.USER_SETTINGS_SCAN_QR_CODE}
|
||||
</TabBar.Item>
|
||||
),
|
||||
|
||||
start() {
|
||||
// Preload images
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue