@@ -22,21 +28,30 @@ export function SigninCard({ signin, handleDelete }): JSX.Element {
+
))}
diff --git a/src/pages/background/index.ts b/src/pages/background/index.ts
index 7ce29234..f7db19be 100644
--- a/src/pages/background/index.ts
+++ b/src/pages/background/index.ts
@@ -5,7 +5,7 @@ import { signifyService } from "@pages/background/services/signify";
import { IMessage } from "@pages/background/types";
import { senderIsPopup } from "@pages/background/utils";
import { getCurrentDomain } from "@pages/background/utils";
-import { deleteSigninByIndex } from "@pages/background/signins-utils";
+import { updateDomainAutoSigninByIndex, deleteSigninByIndex } from "@pages/background/signins-utils";
console.log("Background script loaded");
@@ -148,6 +148,15 @@ chrome.runtime.onMessage.addListener(function (
});
}
+ if (message.type === "update-resource" && message.subtype === "auto-signin") {
+ const resp = await updateDomainAutoSigninByIndex(message?.data?.index, message?.data?.signin);
+ sendResponse({
+ data: {
+ ...resp,
+ },
+ });
+ }
+
if (message.type === "delete-resource" && message.subtype === "signins") {
const resp = await deleteSigninByIndex(message?.data?.index);
sendResponse({
diff --git a/src/pages/background/signins-utils.ts b/src/pages/background/signins-utils.ts
index a8c056b2..f3c30b1c 100644
--- a/src/pages/background/signins-utils.ts
+++ b/src/pages/background/signins-utils.ts
@@ -1,5 +1,23 @@
import { browserStorageService } from "@pages/background/services/browser-storage";
+export const updateDomainAutoSigninByIndex = async (index: number, signin) => {
+ let signins = await browserStorageService.getValue("signins");
+ if (signins?.length) {
+ const newSignins = signins.map((_ele, idx) => {
+ if (idx !== index && _ele.domain !== signin.domain) return _ele;
+
+ if (idx !== index && _ele.domain === signin.domain)
+ return { ..._ele, autoSignin: false };
+
+ return { ..._ele, autoSignin: true };
+ });
+ await browserStorageService.setValue("signins", newSignins);
+ }
+ signins = await browserStorageService.getValue("signins");
+
+ return { signins };
+};
+
export const deleteSigninByIndex = async (index: number) => {
let signins = await browserStorageService.getValue("signins");
let deleted = false;
diff --git a/src/pages/dialog/signin.tsx b/src/pages/dialog/signin.tsx
index 428775b4..adc6e5a6 100644
--- a/src/pages/dialog/signin.tsx
+++ b/src/pages/dialog/signin.tsx
@@ -1,7 +1,6 @@
import { TAB_STATE } from "@pages/popup/constants";
import { setTabState } from "@pages/content/index";
-
// TODO do not pass the full signins stored object (only AID name, schema name, web url)
export const SigninItem = ({ signin }: { signin: any }): JSX.Element => {
const handleClick = async () => {
@@ -21,7 +20,7 @@ export const SigninItem = ({ signin }: { signin: any }): JSX.Element => {
return (
-
+
URL: {signin.domain}
{signin?.identifier ? (
@@ -41,13 +40,35 @@ export const SigninItem = ({ signin }: { signin: any }): JSX.Element => {
Last used: {new Date(signin.updatedAt).toDateString()}
-
+
);
};