UI: Trim owner length for incoming shares

This commit is contained in:
Max Berger
2026-04-25 22:59:31 +02:00
parent 146d4b4a9a
commit 2387eb1e55
2 changed files with 16 additions and 2 deletions

View File

@@ -132,3 +132,17 @@ export function get_element(node, selector) {
}
return /** @type {HTMLElement} */ (element);
}
/**
* Trim a string to the given maximum number of characters
*
* @param {string} str
* @param {number} max
* @returns {str}
*/
export function trim_to_max(str, max) {
if (str.length > max - 2) {
return str.substring(0, max) + "...";
}
return str;
}