Skip to content

Commit

Permalink
web: Simplify code for handling saved session
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Dec 18, 2022
1 parent 4d43c67 commit 00c6759
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions web/src/giscus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export class GiscusWidget extends LitElement {
const url = new URL(origin);
const savedSession = localStorage.getItem(this.GISCUS_SESSION_KEY);
const urlSession = url.searchParams.get('giscus') || '';
this.__session = '';

if (urlSession) {
localStorage.setItem(this.GISCUS_SESSION_KEY, JSON.stringify(urlSession));
Expand All @@ -148,10 +149,9 @@ export class GiscusWidget extends LitElement {

if (savedSession) {
try {
this.__session = JSON.parse(savedSession || '') || '';
this.__session = JSON.parse(savedSession);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
this.__session = '';
localStorage.removeItem(this.GISCUS_SESSION_KEY);
console.warn(
`${this._formatError(e?.message)} Session has been cleared.`
Expand Down

1 comment on commit 00c6759

@vercel
Copy link

@vercel vercel bot commented on 00c6759 Dec 18, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

giscus-component – ./

giscus-component.vercel.app
giscus-component-git-main-giscus.vercel.app
giscus-component-giscus.vercel.app

Please sign in to comment.