mirror of
https://github.com/balzack/databag.git
synced 2025-04-24 10:35:23 +00:00
logout from identity component
This commit is contained in:
parent
daeefa75af
commit
c2bf0e129e
@ -9,19 +9,15 @@ import {
|
||||
} from '@tabler/icons-react'
|
||||
import { modals } from '@mantine/modals';
|
||||
|
||||
export function Identity({ settings, contacts }) {
|
||||
export function Identity({ settings, contacts }: { settings: () => void, contacts: () => void }) {
|
||||
const { state, actions } = useIdentity();
|
||||
const [all, setAll] = useState(false);
|
||||
|
||||
const click = (ev) => {
|
||||
console.log("CLICK", ev.currentTarget.checked);
|
||||
}
|
||||
|
||||
const logout = () => modals.openConfirmModal({
|
||||
title: state.strings.confirmLogout,
|
||||
withCloseButton: false,
|
||||
children: (
|
||||
<Switch label={state.strings.allDevices} value={all} size="md" onChange={(ev) => actions.setAll(ev.currentTarget.checked)} />
|
||||
<Switch label={state.strings.allDevices} size="md" onChange={(ev) => actions.setAll(ev.currentTarget.checked)} />
|
||||
),
|
||||
labels: { confirm: state.strings.logout, cancel: state.strings.cancel },
|
||||
onConfirm: actions.logout,
|
||||
|
@ -17,7 +17,7 @@ export function useIdentity() {
|
||||
}
|
||||
|
||||
const actions = {
|
||||
setAll: (all) => {
|
||||
setAll: (all: boolean) => {
|
||||
updateState({ all });
|
||||
},
|
||||
logout: async () => {
|
||||
|
@ -34,6 +34,7 @@ export function useSettings() {
|
||||
}
|
||||
settings.addConfigListener(setConfig);
|
||||
const setProfile = (profile: Profile) => {
|
||||
console.log("URL: ", identity.getProfileImageUrl());
|
||||
updateState({ profile })
|
||||
}
|
||||
identity.addProfileListener(setProfile)
|
||||
|
@ -65,7 +65,7 @@ export class IdentityModule implements Identity {
|
||||
await this.store.setProfileData(guid, profile);
|
||||
await this.store.setProfileRevision(guid, nextRev);
|
||||
this.profile = profile;
|
||||
this.emitter.emit('profile', this.getProfile());
|
||||
this.emitter.emit('profile', this.setProfile());
|
||||
this.revision = nextRev;
|
||||
if (this.nextRevision === nextRev) {
|
||||
this.nextRevision = null;
|
||||
@ -82,14 +82,14 @@ export class IdentityModule implements Identity {
|
||||
}
|
||||
}
|
||||
|
||||
public getProfile() {
|
||||
public setProfile() {
|
||||
const { guid, handle, name, description, location, image, revision, seal, version, node } = this.profile;
|
||||
return { guid, handle, name, description, location, image, version, node, sealSet: Boolean(seal) };
|
||||
return { guid, handle, name, description, location, imageSet: Boolean(image), version, node, sealSet: Boolean(seal) };
|
||||
}
|
||||
|
||||
public addProfileListener(ev: (profile: Profile) => void): void {
|
||||
this.emitter.on('profile', ev);
|
||||
this.emitter.emit('profile', this.getProfile());
|
||||
this.emitter.emit('profile', this.setProfile());
|
||||
}
|
||||
|
||||
public removeProfileListener(ev: (profile: Profile) => void): void {
|
||||
|
@ -157,7 +157,7 @@ export type Profile = {
|
||||
name: string,
|
||||
description: string,
|
||||
location: string,
|
||||
image: string,
|
||||
imageSet: boolean,
|
||||
sealSet: boolean,
|
||||
version: string,
|
||||
node: string,
|
||||
|
Loading…
x
Reference in New Issue
Block a user