Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions packages/shared/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import { activeProfile, clearActiveProfile, isStrongholdLocked } from './profile
import { resetRouter } from './router'
import { api, destroyActor, resetWallet } from './wallet'

/**
* Notification content
*/
export const notification = writable<string>(null)

/**
* Mobile mode
*/
Expand Down Expand Up @@ -49,6 +44,28 @@ export const clearSendParams = () => sendParams.set({ amount: 0, address: '', me
export const loggedIn = writable<boolean>(false)

/**
* Determines if user can make developer profiles
*/
export const developerMode = persistent<boolean>('developerMode', false)

/**
* Cleanup the signup vars
*/
export const cleanupSignup = () => {
mnemonic.set(null)
strongholdPassword.set(null)
walletPin.set(null)
}

/**
* Log in to the current profile
*/
export const login = () => {
loggedIn.set(true)
}

/**

* Logout from current profile
*/
export const logout = () => {
Expand All @@ -64,7 +81,7 @@ export const logout = () => {
resetWallet()
resetRouter()
clearActiveProfile()
mnemonic.set(null)
loggedIn.set(false)
}

if (!get(isStrongholdLocked)) {
Expand Down
9 changes: 4 additions & 5 deletions packages/shared/lib/router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loggedIn, notification, strongholdPassword, walletPin } from 'shared/lib/app'
import { cleanupSignup, login, strongholdPassword, walletPin } from 'shared/lib/app'
import { profiles } from 'shared/lib/profile'
import { AccountRoutes, AppRoute, SettingsRoutes, SetupType, Tabs, WalletRoutes } from 'shared/lib/typings/routes'
import { get, readable, writable } from 'svelte/store'
Expand All @@ -24,7 +24,6 @@ export const path = readable<string>(null, (set) => {
const updatePath = (): void => {
const pathName = window.location.hash.substr(1)
set(pathName)
notification.set(null)
}

window.addEventListener('hashchange', updatePath)
Expand Down Expand Up @@ -101,7 +100,7 @@ export const routerNext = (event) => {
if (shouldAddProfile) {
nextRoute = AppRoute.Setup
} else {
loggedIn.set(true)
login()
nextRoute = AppRoute.Dashboard
}
break
Expand Down Expand Up @@ -176,7 +175,8 @@ export const routerNext = (event) => {
nextRoute = AppRoute.Congratulations
break
case AppRoute.Congratulations:
loggedIn.set(true)
cleanupSignup()
login()
nextRoute = AppRoute.Dashboard
break
}
Expand Down Expand Up @@ -221,5 +221,4 @@ export const resetRouter = () => {
settingsRoute.set(SettingsRoutes.Init)
dashboardRoute.set(Tabs.Wallet)
deepLinkRequestActive.set(false)
loggedIn.set(false)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="typescript">
import { AccountTile, Button, Text } from 'shared/components'
import { loggedIn } from 'shared/lib/app'
import { closePopup, openPopup } from 'shared/lib/popup'
import { accountRoute, walletRoute } from 'shared/lib/router'
import { AccountRoutes, WalletRoutes } from 'shared/lib/typings/routes'
Expand All @@ -19,7 +20,7 @@

let startInit

if ($walletRoute === WalletRoutes.Init && !$accountsLoaded) {
if ($walletRoute === WalletRoutes.Init && !$accountsLoaded && $loggedIn) {
startInit = Date.now()
openPopup({
type: 'busy',
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/routes/setup/Setup.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="typescript">
import { Button, Checkbox, Illustration, Input, OnboardingLayout, Text } from 'shared/components'
import { cleanupSignup } from 'shared/lib/app'
import { appSettings } from 'shared/lib/appSettings'
import { Electron } from 'shared/lib/electron'
import { hasOnlyWhitespaces } from 'shared/lib/helpers'
Expand Down Expand Up @@ -50,6 +51,7 @@
}

function handleBackClick() {
cleanupSignup()
disposeNewProfile()
dispatch('previous')
}
Expand Down