Skip to content

Commit a186bf2

Browse files
author
Austin Raney
committed
remove usage of array.at method. is not safari <= 15.2 compatible.
see caniuse and #98 for more detail. https://caniuse.com/mdn-javascript_builtins_array_at
1 parent e23959e commit a186bf2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

webapp/src/components/ResourcePage.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export interface IResourcePageProps {
154154

155155
const basename = (path: string): string => {
156156
const parts = path.split("/");
157-
return parts.at(-1) || "";
157+
return parts.length > 0 ? parts[parts.length - 1] : ""
158158
};
159159

160160
const flattenFSStateToFileStatusArray = ({
@@ -321,8 +321,7 @@ export const ResourcePage: React.FC<ResourcePageProps> = (props) => {
321321
} = actionData.payload as OpenFilesFileStatusPayload;
322322

323323
if (targetFile?.isDir) {
324-
const leafDir =
325-
currentDirChain.at(-1) || ({ id: "", name: "" } as FileData);
324+
const leafDir = currentDirChain.length > 0 ? currentDirChain[currentDirChain.length - 1] : ({ id: "", name: "" } as FileData);
326325

327326
if (targetFile.id.length > leafDir.id.length) {
328327
// navigate down the file tree
@@ -463,7 +462,7 @@ export const ResourcePage: React.FC<ResourcePageProps> = (props) => {
463462
];
464463

465464
useEffect(() => {
466-
const leafDir = currentDirChain.at(-1) || rootDir;
465+
const leafDir = currentDirChain.length > 0 ? currentDirChain[currentDirChain.length - 1] : rootDir;
467466
// update files in view
468467
const newFiles = createFilesArray(leafDir, files);
469468
setCurrentFiles(newFiles);

0 commit comments

Comments
 (0)