Clone dish instead of using the current dish.

Use Dish.STRING instead of "string" for get()
This commit is contained in:
j433866 2019-07-01 13:41:48 +01:00
parent dd5038c15b
commit 86c37bab3f
1 changed files with 7 additions and 6 deletions

View File

@ -166,24 +166,25 @@ class Dish {
*/ */
async getTitle(maxLength) { async getTitle(maxLength) {
let title = ""; let title = "";
const cloned = this.clone();
switch (this.type) { switch (this.type) {
case Dish.FILE: case Dish.FILE:
title = this.value.name; title = cloned.value.name;
break; break;
case Dish.LIST_FILE: case Dish.LIST_FILE:
title = `${this.value.length} file(s)`; title = `${cloned.value.length} file(s)`;
break; break;
case Dish.ARRAY_BUFFER: case Dish.ARRAY_BUFFER:
case Dish.BYTE_ARRAY: case Dish.BYTE_ARRAY:
title = await this.detectDishType(); title = await cloned.detectDishType();
if (title === null) { if (title === null) {
this.value = this.value.slice(0, 2048); cloned.value = cloned.value.slice(0, 2048);
title = await this.get("string"); title = await cloned.get(Dish.STRING);
} }
break; break;
default: default:
title = await this.get("string"); title = await cloned.get(Dish.STRING);
} }
title = title.slice(0, maxLength); title = title.slice(0, maxLength);