examples: update mailbox
This commit is contained in:
@@ -3,7 +3,7 @@ const choo = require('../../../')
|
||||
|
||||
module.exports = function (params, state, send) {
|
||||
const mailbox = params.mailbox
|
||||
const messages = state[mailbox + ':messages']
|
||||
const messages = state[mailbox].messages
|
||||
return choo.view`
|
||||
<div>
|
||||
<div class="db cf w-100">
|
||||
|
||||
@@ -4,7 +4,7 @@ module.exports = function (params, state, send) {
|
||||
const mailbox = params.mailbox
|
||||
const message = params.message
|
||||
|
||||
const email = state[mailbox + ':messages'].filter(function (msg) {
|
||||
const email = state[mailbox].messages.filter(function (msg) {
|
||||
return String(msg.id) === message
|
||||
})[0]
|
||||
|
||||
|
||||
@@ -5,9 +5,10 @@ module.exports = function () {
|
||||
return function (params, state, send) {
|
||||
const mailbox = params.mailbox
|
||||
const message = params.message
|
||||
const messages = state[mailbox].messages
|
||||
|
||||
if (message) {
|
||||
const email = state[mailbox + ':messages'].filter(function (msg) {
|
||||
const email = state[mailbox].messages.filter(function (msg) {
|
||||
return String(msg.id) === message
|
||||
})[0]
|
||||
|
||||
@@ -15,7 +16,7 @@ module.exports = function () {
|
||||
<section class="fl mt4 w-80 db">
|
||||
<div>
|
||||
${createHeader()}
|
||||
${state[mailbox + ':messages'].map(function (msg) {
|
||||
${messages.map(function (msg) {
|
||||
return createMessage(msg, mailbox)
|
||||
})}
|
||||
</div>
|
||||
@@ -28,7 +29,7 @@ module.exports = function () {
|
||||
return choo.view`
|
||||
<section class="fl mt4 w-80 db">
|
||||
${createHeader()}
|
||||
${state[mailbox + ':messages'].map(function (msg) {
|
||||
${messages.map(function (msg) {
|
||||
return createMessage(msg, mailbox)
|
||||
})}
|
||||
</section>
|
||||
|
||||
@@ -3,16 +3,15 @@ const choo = require('../../../')
|
||||
const mailboxes = [ 'inbox', 'spam', 'sent' ]
|
||||
|
||||
module.exports = function (params, state, send) {
|
||||
const mailbox = params.mailbox
|
||||
|
||||
return choo.view`
|
||||
<aside class="fl mt4 w-20 db">
|
||||
<ul>
|
||||
<li>
|
||||
<h2 class="f4 b lh0">Mailbox</h2>
|
||||
</li>
|
||||
${mailboxes.map(function (name) {
|
||||
return createLi(name, state[name + ':messages'], mailbox)
|
||||
${mailboxes.map(function (mailbox) {
|
||||
const messages = mailbox.messages
|
||||
return createLi(mailbox, messages, mailbox)
|
||||
})}
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
@@ -2,9 +2,10 @@ const pathname = require('pathname-match')
|
||||
const choo = require('../../../')
|
||||
|
||||
module.exports = function (params, state, send) {
|
||||
const location = state.app.location
|
||||
return choo.view`
|
||||
<span class="fl mt4 w-100 f4 b">
|
||||
URL: ${pathname(state.location) || '/'}
|
||||
URL: ${pathname(location) || '/'}
|
||||
</span>
|
||||
`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user