Skip to content

Commit 5c5d533

Browse files
committed
Revisions per @krassowski
1 parent 42d40e0 commit 5c5d533

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

packages/filebrowser/src/listing.ts

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,20 @@ export class DirListing extends Widget {
827827
const node = nodes[i];
828828
if (item.last_modified) {
829829
const modified = DOMUtils.findElement(node, ITEM_MODIFIED_CLASS);
830-
this.renderer.updateItemModified(
831-
modified,
832-
item.last_modified,
833-
this._modifiedStyle
834-
);
830+
if (this.renderer.updateItemModified !== undefined) {
831+
this.renderer.updateItemModified(
832+
modified,
833+
item.last_modified,
834+
this._modifiedStyle
835+
);
836+
} else {
837+
// Render the date in one of multiple formats, depending on the container's size
838+
modified.textContent = Time.formatHuman(
839+
item.last_modified,
840+
this._modifiedStyle
841+
);
842+
modified.title = Time.format(new Date(item.last_modified));
843+
}
835844
}
836845
});
837846
}
@@ -844,11 +853,11 @@ export class DirListing extends Widget {
844853
this.renderer.updateItemNode(
845854
node,
846855
item,
847-
this._modifiedStyle,
848856
ft,
849857
this.translator,
850858
this._hiddenColumns,
851-
this.selection[item.path]
859+
this.selection[item.path],
860+
this._modifiedStyle
852861
);
853862
if (
854863
this.selection[item.path] &&
@@ -2255,7 +2264,7 @@ export namespace DirListing {
22552264
*
22562265
* @param modifiedStyle - The date style for the modified column: narrow, short, or long
22572266
*/
2258-
updateItemModified(
2267+
updateItemModified?(
22592268
modified: HTMLElement,
22602269
modifiedDate: string,
22612270
modifiedStyle: Time.HumanStyle
@@ -2275,11 +2284,11 @@ export namespace DirListing {
22752284
updateItemNode(
22762285
node: HTMLElement,
22772286
model: Contents.IModel,
2278-
modifiedStyle: Time.HumanStyle,
22792287
fileType?: DocumentRegistry.IFileType,
22802288
translator?: ITranslator,
22812289
hiddenColumns?: Set<DirListing.ToggleableColumn>,
2282-
selected?: boolean
2290+
selected?: boolean,
2291+
modifiedStyle?: Time.HumanStyle
22832292
): void;
22842293

22852294
/**
@@ -2604,9 +2613,10 @@ export namespace DirListing {
26042613
let modText = '';
26052614
let modTitle = '';
26062615

2616+
const parsedDate = new Date(modifiedDate);
26072617
// Render the date in one of multiple formats, depending on the container's size
2608-
modText = Time.formatHuman(new Date(modifiedDate), modifiedStyle);
2609-
modTitle = Time.format(new Date(modifiedDate));
2618+
modText = Time.formatHuman(parsedDate, modifiedStyle);
2619+
modTitle = Time.format(parsedDate);
26102620

26112621
modified.textContent = modText;
26122622
modified.title = modTitle;
@@ -2625,11 +2635,11 @@ export namespace DirListing {
26252635
updateItemNode(
26262636
node: HTMLElement,
26272637
model: Contents.IModel,
2628-
modifiedStyle: Time.HumanStyle,
26292638
fileType?: DocumentRegistry.IFileType,
26302639
translator?: ITranslator,
26312640
hiddenColumns?: Set<DirListing.ToggleableColumn>,
2632-
selected?: boolean
2641+
selected?: boolean,
2642+
modifiedStyle?: Time.HumanStyle
26332643
): void {
26342644
if (selected) {
26352645
node.classList.add(SELECTED_CLASS);
@@ -2750,7 +2760,11 @@ export namespace DirListing {
27502760
}
27512761

27522762
if (model.last_modified) {
2753-
this.updateItemModified(modified, model.last_modified, modifiedStyle);
2763+
this.updateItemModified(
2764+
modified,
2765+
model.last_modified,
2766+
modifiedStyle ?? 'short'
2767+
);
27542768
}
27552769
}
27562770

0 commit comments

Comments
 (0)