mirror of
https://github.com/HeyPuter/puter.git
synced 2026-01-05 20:50:22 -06:00
refactor: Put truncate_filename() helper in its own file
Every user previously set the max_length as window.TRUNCATE_LENGTH, so I've moved that constant into the truncate_filename file and set it as the default if max_length is not specified.
This commit is contained in:
@@ -36,6 +36,7 @@ import refresh_item_container from "../helpers/refresh_item_container.js"
|
||||
import changeLanguage from "../i18n/i18nChangeLanguage.js"
|
||||
import UIWindowSettings from "./Settings/UIWindowSettings.js"
|
||||
import UIWindowTaskManager from "./UIWindowTaskManager.js"
|
||||
import truncate_filename from '../helpers/truncate_filename.js';
|
||||
|
||||
async function UIDesktop(options){
|
||||
let h = '';
|
||||
@@ -150,7 +151,7 @@ async function UIDesktop(options){
|
||||
|
||||
// Update matching items
|
||||
// set new item name
|
||||
$(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(window.truncate_filename(item.name, window.TRUNCATE_LENGTH)).replaceAll(' ', ' '));
|
||||
$(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(truncate_filename(item.name)).replaceAll(' ', ' '));
|
||||
|
||||
// Set new icon
|
||||
const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await window.item_icon(item)).image);
|
||||
@@ -354,7 +355,7 @@ async function UIDesktop(options){
|
||||
|
||||
// Update matching items
|
||||
// Set new item name
|
||||
$(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(window.truncate_filename(item.name, window.TRUNCATE_LENGTH)).replaceAll(' ', ' '));
|
||||
$(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(truncate_filename(item.name)).replaceAll(' ', ' '));
|
||||
|
||||
// Set new icon
|
||||
const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await window.item_icon(item)).image);
|
||||
|
||||
Reference in New Issue
Block a user