Add getDishTitle function

This commit is contained in:
j433866 2019-06-13 09:43:58 +01:00
parent f497dc3170
commit 6ee76e3bf0
5 changed files with 102 additions and 3 deletions

View file

@ -68,6 +68,9 @@ self.addEventListener("message", function(e) {
case "getDishAs":
getDishAs(r.data);
break;
case "getDishTitle":
getDishTitle(r.data);
break;
case "docURL":
// Used to set the URL of the current document so that scripts can be
// imported into an inline worker.
@ -158,6 +161,26 @@ async function getDishAs(data) {
}
/**
* Gets the dish title
*
* @param {object} data
* @param {Dish} data.dish
* @param {number} data.maxLength
* @param {number} data.id
*/
async function getDishTitle(data) {
const title = await self.chef.getDishTitle(data.dish, data.maxLength);
self.postMessage({
action: "dishReturned",
data: {
value: title,
id: data.id
}
});
}
/**
* Calculates highlight offsets if possible.
*