Clone dish instead of using the current dish.
Use Dish.STRING instead of "string" for get()
This commit is contained in:
parent
dd5038c15b
commit
86c37bab3f
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user