Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make logout from settings modal functional #241

Closed

Conversation

GamerGirlandCo
Copy link

@GamerGirlandCo GamerGirlandCo commented May 28, 2023

Please make sure to check the following tasks before opening and submitting a PR

  • I understand and have followed the contribution guide
  • I have tested my changes locally and they are working as intended
  • These changes do not have any notable side effects on other Revolt projects

closes #242

@github-actions
Copy link

github-actions bot commented May 28, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@GamerGirlandCo
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@nulldg
Copy link

nulldg commented Jun 1, 2023

closes #242

nulldg

This comment was marked as outdated.

Copy link

@nulldg nulldg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@@ -196,6 +197,14 @@ const Config: SettingsConfiguration<{ server: Server }> = {
{
id: "logout",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omit id, only onClick is necessary.

@@ -227,4 +236,5 @@ const ClientSettingsRouting: Record<string, Component> = {
sync,
native,
experiments,
logout,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once id is omitted, this component no longer needs to be included.

href: "/login",
onClick: () => {
const acli = getController("state");
const cli = getController("client").getCurrentClient();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client is available through context here, add const client = useClient() at the top of the function instead of using this line here.

@@ -196,6 +197,14 @@ const Config: SettingsConfiguration<{ server: Server }> = {
{
id: "logout",
icon: <BiSolidExit size={20} color={theme!.colours.error} />,
href: "/login",
onClick: () => {
const acli = getController("state");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package should also have direct access to state and it can be called through state.

onClick: () => {
const acli = getController("state");
const cli = getController("client").getCurrentClient();
console.log(cli);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extraneous print statement

const acli = getController("state");
const cli = getController("client").getCurrentClient();
console.log(cli);
acli.auth.removeSession(cli?.user?.id as string);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will remove the session from storage but not kill the active client in the client controller, which is remedied by assigning window.location.href (since that will just kill all active sessions) but we want to avoid reloading the client.

const cli = getController("client").getCurrentClient();
console.log(cli);
acli.auth.removeSession(cli?.user?.id as string);
window.location.href = "/login";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should useNavigate from routing package at top of component, and then use navigate function instead of telling the browser to redirect us.

@insertish insertish marked this pull request as draft June 9, 2023 10:09
@insertish
Copy link
Member

PR is stale, requested changes ignored, closing out for now

@insertish insertish closed this Dec 1, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

feat: logout
3 participants