Avivash/update old username format in init (#106)

This commit is contained in:
Andrew Vivash 2023-01-05 12:24:51 -08:00 committed by GitHub
parent b0b9a2020e
commit 14b554d098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -3,7 +3,7 @@ import * as webnative from 'webnative'
import { dev } from '$app/environment'
import { filesystemStore, sessionStore } from '../stores'
import { getBackupStatus, type BackupStatus } from '$lib/auth/backup'
import { USERNAME_STORAGE_KEY } from '$lib/auth/account'
import { USERNAME_STORAGE_KEY, createDID } from '$lib/auth/account'
import { webnativeNamespace } from '$lib/app-info'
export const initialize = async (): Promise<void> => {
@ -19,7 +19,16 @@ export const initialize = async (): Promise<void> => {
// Authed
backupStatus = await getBackupStatus(program.session.fs)
const fullUsername = await program.components.storage.getItem(USERNAME_STORAGE_KEY) as string
let fullUsername = await program.components.storage.getItem(USERNAME_STORAGE_KEY) as string
// If the user is migrating from a version webnative-app-template before https://github.com/webnative-examples/webnative-app-template/pull/97/files#diff-a180510e798b8f833ebfdbe691c5ec4a1095076980d3e2388de29c849b2b8361R44,
// their username won't contain a did, so we will need to manually append a DID and add it storage here
if (!fullUsername) {
const did = await createDID(program.components.crypto)
fullUsername = `${program.session.username}#${did}`
await program.components.storage.setItem(USERNAME_STORAGE_KEY, fullUsername)
window.location.reload()
}
sessionStore.set({
username: {

View File

@ -56,7 +56,8 @@
$themeStore.selectedTheme === 'light' ? '#FAFAFA' : '#171717',
padding: 0,
width: 250,
height: 250
height: 250,
join: true
}).svg()
initAccountLinkingProducer(hashedUsername)