feat: Improve menu (#109)

* Return empty array if no match on week

Better to handle empty response in client

* Parse all descriptions to markdown

To get rid of <br/> and other stuff

Co-authored-by: Johan Öbrink <johan.obrink@gmail.com>
This commit is contained in:
Andreas Eriksson 2021-04-16 16:57:16 +02:00 committed by GitHub
parent 0a02ffa04d
commit 9c4fcb2d25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 12 deletions

View File

@ -387,7 +387,7 @@ export class Api extends EventEmitter {
}
public async getMenu(child: EtjanstChild): Promise<MenuItem[]> {
if (this.isFake) return fakeResponse(fake.menu(child))
if (this.isFake) return fakeResponse(fake.menu(child).map(parse.menuItem))
const menuService = await this.getMenuChoice(child)
if (menuService === 'rss') {

View File

@ -18,34 +18,29 @@ export const menuList = (data: any): MenuItem[] => {
)
if (!currentWeek) {
return [
{
title: 'Måndag - Vecka ?',
description: 'Hittade ingen meny',
},
]
return []
}
const menuItemsFS = [
{
title: `Måndag - Vecka ${currentWeek.week}`,
description: currentWeek.mon,
description: toMarkdown(currentWeek.mon) ,
},
{
title: `Tisdag - Vecka ${currentWeek.week}`,
description: currentWeek.tue,
description: toMarkdown(currentWeek.tue),
},
{
title: `Onsdag - Vecka ${currentWeek.week}`,
description: currentWeek.wed,
description: toMarkdown(currentWeek.wed),
},
{
title: `Torsdag - Vecka ${currentWeek.week}`,
description: currentWeek.thu,
description: toMarkdown(currentWeek.thu),
},
{
title: `Fredag - Vecka ${currentWeek.week}`,
description: currentWeek.fri,
description: toMarkdown(currentWeek.fri),
},
]