Created
October 25, 2016 20:27
-
-
Save rondale-sc/6bebec33349249387e9492492b3280da to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| model(params) { | |
| let shoebox = this.get('fastboot.shoebox'); | |
| let shoeboxStore = shoebox.retrieve('my-store'); | |
| if (this.get('fastboot.isFastBoot')) { | |
| return this.store.queryRecord('episode', { slug: params.slug }).then(episode => { | |
| if(!shoeboxStore){ | |
| shoeboxStore = {}; | |
| shoebox.put('my-store', shoeboxStore); | |
| } | |
| const pushData = episode.serialize({includeId: true}); | |
| const includeds = []; | |
| episode.get('showNotes').map(function(showNote) { | |
| includeds.push(showNote.serialize({includeId: true}).data); | |
| includeds.push(showNote.get('resource').serialize({includeId: true}).data); | |
| showNote.get('authors').map(function(author) { | |
| includeds.push(author.serialize({includeId: true}).data); | |
| }); | |
| }); | |
| pushData.included = includeds; | |
| shoeboxStore[params.slug] = pushData | |
| }); | |
| } else { | |
| const pushData = shoeboxStore[params.slug]; | |
| this.store.pushPayload(pushData); | |
| const model = this.store.peekRecord('episode', pushData.data.id); | |
| return model; | |
| } | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment