From 4056f3ef8da64e1634f753c039619ed5fc52010d Mon Sep 17 00:00:00 2001 From: Samuel Andert Date: Fri, 21 Jul 2023 12:24:08 +0200 Subject: [PATCH] added basic messaging mockup --- src/lib/GoogleAuth.svelte | 23 ++++++++-- src/lib/components/Messages.svelte | 71 ++++++++++++++++++++++++++++++ src/lib/data/dummyMessages.js | 12 +++++ src/routes/google/+page.svelte | 5 --- src/routes/log/+page.svelte | 5 +++ 5 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 src/lib/components/Messages.svelte create mode 100644 src/lib/data/dummyMessages.js delete mode 100644 src/routes/google/+page.svelte create mode 100644 src/routes/log/+page.svelte diff --git a/src/lib/GoogleAuth.svelte b/src/lib/GoogleAuth.svelte index 6f31f86..bea7fab 100644 --- a/src/lib/GoogleAuth.svelte +++ b/src/lib/GoogleAuth.svelte @@ -8,7 +8,7 @@ getProviderFromUrl } from '@lit-protocol/lit-auth-client'; import { LitNodeClient } from '@lit-protocol/lit-node-client'; - import { IRelayPKP, AuthMethod, SessionSigs } from '@lit-protocol/types'; + import { IRelayPKP } from '@lit-protocol/types'; import { ProviderType } from '@lit-protocol/constants'; import { LitAccessControlConditionResource, LitAbility } from '@lit-protocol/auth-helpers'; @@ -24,14 +24,22 @@ let sessionSigs; let isLoading = false; + // Add an array to store chat messages + let messages: string[] = []; + + // Helper function to add a message to the chat + function addMessage(message: string) { + messages = [...messages, message]; + } async function authWithGoogle() { isLoading = true; error = null; + // Add chat message updates + addMessage('Starting authentication with Google...'); try { - console.log('Starting authentication with Google...'); const provider = litAuthClient.initProvider(ProviderType.Google); await provider.signIn(); - console.log('Handling Google authentication...'); + addMessage('Handling Google authentication...'); await handleRedirect(ProviderType.Google); } catch (err) { console.error(err); @@ -82,6 +90,9 @@ } console.log(`Handling redirect for ${providerName}`); console.log(`Fetched PKPs: ${pkps.length}`); + // Add chat message updates + addMessage(`Handling redirect for ${providerName}`); + addMessage(`Fetched PKPs: ${pkps.length}`); } async function mint() { isLoading = true; @@ -237,3 +248,9 @@ {/if} + +{#each messages as message, index} +
+

{message}

+
+{/each} diff --git a/src/lib/components/Messages.svelte b/src/lib/components/Messages.svelte new file mode 100644 index 0000000..c6a595c --- /dev/null +++ b/src/lib/components/Messages.svelte @@ -0,0 +1,71 @@ + + + +
+ {#each messages as message} +
+

{message.text}

+ {message.timestamp} +
+ {/each} +
+ +
+ + +
+ + diff --git a/src/lib/data/dummyMessages.js b/src/lib/data/dummyMessages.js new file mode 100644 index 0000000..8c785cc --- /dev/null +++ b/src/lib/data/dummyMessages.js @@ -0,0 +1,12 @@ +export const dummyMessages = [ + { text: "Believe you can, and you're halfway there.", timestamp: '2023-07-21 12:34:56' }, + { text: "The only way to do great work is to love what you do.", timestamp: '2023-07-21 12:36:22' }, + { text: "Success is not final, failure is not fatal: It is the courage to continue that counts.", timestamp: '2023-07-21 12:40:10' }, + { text: "The best way to predict the future is to create it.", timestamp: '2023-07-21 12:45:34' }, + { text: "Your time is limited, don't waste it living someone else's life.", timestamp: '2023-07-21 13:01:05' }, + { text: "Every moment is a fresh beginning.", timestamp: '2023-07-21 13:10:22' }, + { text: "Don't watch the clock; do what it does. Keep going.", timestamp: '2023-07-21 13:25:45' }, + { text: "Believe in yourself and all that you are. Know that there is something inside you that is greater than any obstacle.", timestamp: '2023-07-21 13:40:15' }, + { text: "You are never too old to set another goal or to dream a new dream.", timestamp: '2023-07-21 14:05:07' }, + { text: "The future belongs to those who believe in the beauty of their dreams.", timestamp: '2023-07-21 14:20:59' }, + ]; \ No newline at end of file diff --git a/src/routes/google/+page.svelte b/src/routes/google/+page.svelte deleted file mode 100644 index c22d014..0000000 --- a/src/routes/google/+page.svelte +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/src/routes/log/+page.svelte b/src/routes/log/+page.svelte new file mode 100644 index 0000000..9d093d6 --- /dev/null +++ b/src/routes/log/+page.svelte @@ -0,0 +1,5 @@ + + +