further improved the session logic
This commit is contained in:
		@@ -23,6 +23,14 @@
 | 
			
		||||
  let messageToSign = { user: "Sam", loggedIn: true };
 | 
			
		||||
 | 
			
		||||
  onMount(async () => {
 | 
			
		||||
    // Load activeSession from local storage
 | 
			
		||||
    const storedSession = localStorage.getItem("google-session");
 | 
			
		||||
    const storedPKP = localStorage.getItem("current-pkp");
 | 
			
		||||
    if (storedSession && storedPKP) {
 | 
			
		||||
      activeSession = JSON.parse(storedSession);
 | 
			
		||||
      currentPKP = JSON.parse(storedPKP);
 | 
			
		||||
      view = "READY";
 | 
			
		||||
    }
 | 
			
		||||
    initialize();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
@@ -147,23 +155,25 @@
 | 
			
		||||
      Signer
 | 
			
		||||
      <Signer {messageToSign} />
 | 
			
		||||
      Sessions
 | 
			
		||||
      {#if activeSession}
 | 
			
		||||
        <div>
 | 
			
		||||
          <h3>Active Session:</h3>
 | 
			
		||||
          <p>Node: {activeSession.node}</p>
 | 
			
		||||
          <p>Session Key: {activeSession.sessionKey}</p>
 | 
			
		||||
          <p>Expiration: {activeSession.expiration}</p>
 | 
			
		||||
        </div>
 | 
			
		||||
      {/if}
 | 
			
		||||
      {#each sessionStatuses as { node, sessionKey, expiration, isExpired }}
 | 
			
		||||
        <p>
 | 
			
		||||
          {isExpired ? "🔴" : "🟢"} Node: {node}, Session Key: {sessionKey},
 | 
			
		||||
          Expiration: {expiration}
 | 
			
		||||
        </p>
 | 
			
		||||
      {/each}
 | 
			
		||||
    {/if}
 | 
			
		||||
    <div class="mt-4 text-center">
 | 
			
		||||
      <p>{status}</p>
 | 
			
		||||
    </div>
 | 
			
		||||
    {#if activeSession}
 | 
			
		||||
      <div>
 | 
			
		||||
        <h3>Active Session:</h3>
 | 
			
		||||
        <p>Node: {activeSession.node}</p>
 | 
			
		||||
        <p>Session Key: {activeSession.sessionKey}</p>
 | 
			
		||||
        <p>Expiration: {activeSession.expiration}</p>
 | 
			
		||||
      </div>
 | 
			
		||||
      {#if sessionStatuses}
 | 
			
		||||
        {#each sessionStatuses as { node, sessionKey, expiration, isExpired }}
 | 
			
		||||
          <p>
 | 
			
		||||
            {isExpired ? "🔴" : "🟢"} Node: {node}, Session Key: {sessionKey},
 | 
			
		||||
            Expiration: {expiration}
 | 
			
		||||
          </p>
 | 
			
		||||
        {/each}
 | 
			
		||||
      {/if}
 | 
			
		||||
    {/if}
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user