From c0f2c974587d75a38e3e753368ef0e2e2be139fd Mon Sep 17 00:00:00 2001
From: Vendicated <vendicated@riseup.net>
Date: Fri, 6 Oct 2023 19:40:53 +0200
Subject: ReviewDB: proper multi account support

---
 src/plugins/reviewDB/settings.tsx | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

(limited to 'src/plugins/reviewDB/settings.tsx')

diff --git a/src/plugins/reviewDB/settings.tsx b/src/plugins/reviewDB/settings.tsx
index e318bc7..cf61a38 100644
--- a/src/plugins/reviewDB/settings.tsx
+++ b/src/plugins/reviewDB/settings.tsx
@@ -20,8 +20,7 @@ import { definePluginSettings } from "@api/Settings";
 import { OptionType } from "@utils/types";
 import { Button } from "@webpack/common";
 
-import { ReviewDBUser } from "./entities";
-import { authorize } from "./utils";
+import { authorize, getToken } from "./auth";
 
 export const settings = definePluginSettings({
     authorize: {
@@ -57,10 +56,11 @@ export const settings = definePluginSettings({
         type: OptionType.COMPONENT,
         description: "ReviewDB website",
         component: () => (
-            <Button onClick={() => {
+            <Button onClick={async () => {
                 let url = "https://reviewdb.mantikafasi.dev/";
-                if (settings.store.token)
-                    url += "/api/redirect?token=" + encodeURIComponent(settings.store.token);
+                const token = await getToken();
+                if (token)
+                    url += "/api/redirect?token=" + encodeURIComponent(token);
 
                 VencordNative.native.openExternal(url);
             }}>
@@ -80,8 +80,6 @@ export const settings = definePluginSettings({
         )
     }
 }).withPrivateSettings<{
-    token?: string;
-    user?: ReviewDBUser;
     lastReviewId?: number;
     reviewsDropdownState?: boolean;
 }>();
-- 
cgit 

