Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix directory modtime
  • Loading branch information
sawka committed Mar 11, 2026
commit acd821e2c5750aeee2c0494404a43b2d2c0d1d2b
6 changes: 4 additions & 2 deletions frontend/app/view/preview/directorypreview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
white-space: nowrap;
padding: 0.25rem;
cursor: default;
font-size: 0.8125rem;
font-size: 12px;
flex: 0 0 auto;

&.col-size {
Expand All @@ -154,8 +154,10 @@
margin-right: 12px;
}

.dir-table-modestr {
.dir-table-modestr,
.dir-table-lastmod {
font-family: Hack;
font-size: 11px;
}

.dir-table-name {
Expand Down
30 changes: 14 additions & 16 deletions frontend/app/view/preview/preview-directory-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { globalStore } from "@/app/store/global";
import { RpcApi } from "@/app/store/wshclientapi";
import { TabRpcClient } from "@/app/store/wshrpcutil";
import { fireAndForget, isBlank } from "@/util/util";
import { Column } from "@tanstack/react-table";
import dayjs from "dayjs";
import React from "react";
import { type PreviewModel } from "./preview-model";
Expand Down Expand Up @@ -40,23 +39,22 @@ export function getBestUnit(bytes: number, si = false, sigfig = 3): string {
return `${parseFloat(value.toPrecision(sigfig))}${displaySuffixes[unit] ?? unit}`;
}

export function getLastModifiedTime(unixMillis: number, column: Column<FileInfo, number>): string {
const fileDatetime = dayjs(new Date(unixMillis));
const nowDatetime = dayjs(new Date());

let datePortion: string;
if (nowDatetime.isSame(fileDatetime, "date")) {
datePortion = "Today";
} else if (nowDatetime.subtract(1, "day").isSame(fileDatetime, "date")) {
datePortion = "Yesterday";
} else {
datePortion = dayjs(fileDatetime).format("M/D/YY");
}
function padDay(day: number) {
return String(day).padStart(2, " ");
}

export function getLastModifiedTime(unixMillis: number): string {
const file = dayjs(unixMillis);
const now = dayjs();

if (column.getSize() > 120) {
return `${datePortion}, ${dayjs(fileDatetime).format("h:mm A")}`;
const day = padDay(file.date());
const time = file.format("HH:mm");

if (now.isSame(file, "year")) {
return `${file.format("MMM")} ${day} ${time}`;
}
return datePortion;

return `${file.format("YYYY-MM-DD")}`;
}

const iconRegex = /^[a-z0-9- ]+$/;
Expand Down
12 changes: 2 additions & 10 deletions frontend/app/view/preview/preview-directory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function DirectoryTable({
}),
columnHelper.accessor("modtime", {
cell: (info) => (
<span className="dir-table-lastmod">{getLastModifiedTime(info.getValue(), info.column)}</span>
<span className="dir-table-lastmod">{getLastModifiedTime(info.getValue())}</span>
),
header: () => <span>Last Modified</span>,
size: 91,
Expand Down Expand Up @@ -493,15 +493,7 @@ type TableRowProps = {
handleFileContextMenu: (e: any, finfo: FileInfo) => Promise<void>;
};

function TableRow({
model,
row,
focusIndex,
setFocusIndex,
setSearch,
idx,
handleFileContextMenu,
}: TableRowProps) {
function TableRow({ model, row, focusIndex, setFocusIndex, setSearch, idx, handleFileContextMenu }: TableRowProps) {
const dirPath = useAtomValue(model.statFilePath);
const connection = useAtomValue(model.connection);

Expand Down