This repository has been archived by the owner on Oct 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet): Persist wallet information
- Loading branch information
Showing
13 changed files
with
512 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
import Route from '@ember/routing/route'; | ||
import { get } from '@ember/object'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default Route.extend({ | ||
redirect() { | ||
const wallet = this.store.createRecord('wallet'); | ||
this.transitionTo('wallets', wallet.save()); | ||
settings: service('settings'), | ||
|
||
async redirect() { | ||
const settings = get(this, 'settings'); | ||
let wallet = settings.get('wallet'); | ||
if (!wallet) { | ||
wallet = await this.store.createRecord('wallet').save(); | ||
settings.setProperties(this.store.serialize(wallet, { includeId: true })); | ||
} | ||
|
||
return this.transitionTo('wallets', wallet); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Service from '@ember/service'; | ||
import { | ||
get, | ||
set, | ||
getProperties, | ||
setProperties, | ||
getWithDefault, | ||
} from '@ember/object'; | ||
|
||
import { storageFor } from 'ember-local-storage'; | ||
|
||
export default Service.extend({ | ||
settings: storageFor('settings'), | ||
|
||
get(keyName) { | ||
const settings = get(this, 'settings'); | ||
return get(settings, keyName); | ||
}, | ||
|
||
set(keyName, value) { | ||
const settings = get(this, 'settings'); | ||
return set(settings, keyName, value); | ||
}, | ||
|
||
getProperties(...args) { | ||
const settings = get(this, 'settings'); | ||
return getProperties(settings, ...args); | ||
}, | ||
|
||
setProperties(hash) { | ||
const settings = get(this, 'settings'); | ||
return setProperties(settings, hash); | ||
}, | ||
|
||
getWithDefault(keyName, defaultValue) { | ||
const settings = get(this, 'settings'); | ||
return getWithDefault(settings, keyName, defaultValue); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import StorageObject from 'ember-local-storage/local/object'; | ||
|
||
const Storage = StorageObject.extend(); | ||
|
||
// Uncomment if you would like to set initialState | ||
Storage.reopenClass({ | ||
initialState() { | ||
return { | ||
wallet: null, | ||
}; | ||
} | ||
}); | ||
|
||
export default Storage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
breadCrumb: { | ||
title: 'Account', | ||
path: 'wallets.accounts', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
breadCrumb: { | ||
title: 'Wallet', | ||
path: 'wallets.overview', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.