mirror of
https://github.com/gabehf/Koito.git
synced 2026-04-22 20:11:50 -07:00
alter rewind nav to default to monthly rewind
This commit is contained in:
parent
a0b32f756e
commit
9678117c05
2 changed files with 10 additions and 7 deletions
|
|
@ -2,7 +2,7 @@ import { ExternalLink, History, Home, Info } from "lucide-react";
|
||||||
import SidebarSearch from "./SidebarSearch";
|
import SidebarSearch from "./SidebarSearch";
|
||||||
import SidebarItem from "./SidebarItem";
|
import SidebarItem from "./SidebarItem";
|
||||||
import SidebarSettings from "./SidebarSettings";
|
import SidebarSettings from "./SidebarSettings";
|
||||||
import { getRewindYear } from "~/utils/utils";
|
import { getRewindParams, getRewindYear } from "~/utils/utils";
|
||||||
|
|
||||||
export default function Sidebar() {
|
export default function Sidebar() {
|
||||||
const iconSize = 20;
|
const iconSize = 20;
|
||||||
|
|
@ -45,7 +45,7 @@ export default function Sidebar() {
|
||||||
<SidebarSearch size={iconSize} />
|
<SidebarSearch size={iconSize} />
|
||||||
<SidebarItem
|
<SidebarItem
|
||||||
space={10}
|
space={10}
|
||||||
to={`/rewind?year=${getRewindYear()}`}
|
to={`/rewind?${getRewindParams()}`}
|
||||||
name="Rewind"
|
name="Rewind"
|
||||||
onClick={() => {}}
|
onClick={() => {}}
|
||||||
modal={<></>}
|
modal={<></>}
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,15 @@ const timeframeToInterval = (timeframe: Timeframe): string => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getRewindYear = (): number => {
|
const getRewindYear = (): number => {
|
||||||
|
return new Date().getFullYear() - 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getRewindParams = (): string => {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
if (today.getMonth() > 10 && today.getDate() >= 30) {
|
if (today.getMonth() == 0) {
|
||||||
// if we are in december 30/31, just serve current year
|
return `year=${today.getFullYear() - 1}`;
|
||||||
return today.getFullYear();
|
|
||||||
} else {
|
} else {
|
||||||
return today.getFullYear() - 1;
|
return `month=${today.getMonth()}`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -114,5 +117,5 @@ const timeListenedString = (seconds: number) => {
|
||||||
return `${minutes} minutes listened`;
|
return `${minutes} minutes listened`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export { hexToHSL, timeListenedString, getRewindYear };
|
export { hexToHSL, timeListenedString, getRewindYear, getRewindParams };
|
||||||
export type { hsl };
|
export type { hsl };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue