From 4def6eef5a5a8f0702cfb93fac99fb0f243b250b Mon Sep 17 00:00:00 2001
From: Lim Chee Aun <cheeaun@gmail.com>
Date: Sun, 31 Mar 2024 20:53:08 +0800
Subject: [PATCH] Refactor this out for no particular reason

---
 src/components/media.jsx      |  2 +-
 src/components/status.jsx     | 15 ---------------
 src/utils/format-duration.jsx | 14 ++++++++++++++
 3 files changed, 15 insertions(+), 16 deletions(-)
 create mode 100644 src/utils/format-duration.jsx

diff --git a/src/components/media.jsx b/src/components/media.jsx
index abb343cb..e73a8a4e 100644
--- a/src/components/media.jsx
+++ b/src/components/media.jsx
@@ -9,12 +9,12 @@ import {
 } from 'preact/hooks';
 import QuickPinchZoom, { make3dTransformValue } from 'react-quick-pinch-zoom';
 
+import formatDuration from '../utils/format-duration';
 import mem from '../utils/mem';
 import states from '../utils/states';
 
 import Icon from './icon';
 import Link from './link';
-import { formatDuration } from './status';
 
 const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); // https://stackoverflow.com/a/23522755
 
diff --git a/src/components/status.jsx b/src/components/status.jsx
index a34b4e90..d4e66a5a 100644
--- a/src/components/status.jsx
+++ b/src/components/status.jsx
@@ -2872,21 +2872,6 @@ function StatusButton({
   );
 }
 
-export function formatDuration(time) {
-  if (!time) return;
-  let hours = Math.floor(time / 3600);
-  let minutes = Math.floor((time % 3600) / 60);
-  let seconds = Math.round(time % 60);
-
-  if (hours === 0) {
-    return `${minutes}:${seconds.toString().padStart(2, '0')}`;
-  } else {
-    return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds
-      .toString()
-      .padStart(2, '0')}`;
-  }
-}
-
 function nicePostURL(url) {
   if (!url) return;
   const urlObj = new URL(url);
diff --git a/src/utils/format-duration.jsx b/src/utils/format-duration.jsx
new file mode 100644
index 00000000..935faa9a
--- /dev/null
+++ b/src/utils/format-duration.jsx
@@ -0,0 +1,14 @@
+export default function formatDuration(time) {
+  if (!time) return;
+  let hours = Math.floor(time / 3600);
+  let minutes = Math.floor((time % 3600) / 60);
+  let seconds = Math.round(time % 60);
+
+  if (hours === 0) {
+    return `${minutes}:${seconds.toString().padStart(2, '0')}`;
+  } else {
+    return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds
+      .toString()
+      .padStart(2, '0')}`;
+  }
+}