From 6b4d7cd4d1fb2d1c2550f90a75c7445ca2c1e79a Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Wed, 13 Sep 2023 01:57:58 -0700
Subject: refactor(history): move to history route

---
 src/routes/activity-history/+page.svelte | 94 --------------------------------
 1 file changed, 94 deletions(-)
 delete mode 100644 src/routes/activity-history/+page.svelte

(limited to 'src/routes/activity-history/+page.svelte')

diff --git a/src/routes/activity-history/+page.svelte b/src/routes/activity-history/+page.svelte
deleted file mode 100644
index 2bb0f129..00000000
--- a/src/routes/activity-history/+page.svelte
+++ /dev/null
@@ -1,94 +0,0 @@
-<script lang="ts">
-	import { activityHistory, type ActivityHistoryEntry } from '$lib/AniList/activity.js';
-	import { onMount } from 'svelte';
-	import userIdentity from '../../stores/userIdentity.js';
-	import { userIdentity as getUserIdentity } from '$lib/AniList/identity';
-
-	export let data;
-
-	let activityHistoryData: Promise<ActivityHistoryEntry[]>;
-	let currentUserIdentity = { name: '', id: -1 };
-	const timezoneOffset = new Date().getTimezoneOffset() * 60 * 1000;
-
-	onMount(async () => {
-		if (data.user !== undefined) {
-			if ($userIdentity === '') {
-				userIdentity.set(JSON.stringify(await getUserIdentity(data.user)));
-			}
-
-			currentUserIdentity = JSON.parse($userIdentity);
-			currentUserIdentity.name = currentUserIdentity.name;
-			activityHistoryData = activityHistory(currentUserIdentity);
-			console.log(fillMissingDays(await activityHistory(currentUserIdentity)));
-		}
-	});
-
-	const fillMissingDays = (inputActivities: ActivityHistoryEntry[]): ActivityHistoryEntry[] => {
-		let activities = inputActivities;
-		const firstDate = new Date(activities[0].date * 1000 + timezoneOffset);
-		const lastDate = new Date(activities[activities.length - 1].date * 1000 + timezoneOffset);
-		const currentDate = firstDate;
-
-		while (currentDate <= lastDate) {
-			const current_unix_timestamp = currentDate.getTime();
-			let found = false;
-
-			for (let i = 0; i < activities.length; i++) {
-				if (activities[i].date * 1000 + timezoneOffset === current_unix_timestamp) {
-					found = true;
-
-					break;
-				}
-			}
-
-			if (!found) {
-				activities.push({
-					date: current_unix_timestamp / 1000,
-					amount: 0
-				});
-			}
-
-			currentDate.setDate(currentDate.getDate() + 1);
-		}
-
-		// activities.sort((a: { date: number }, b: { date: number }) => a.date - b.date);
-
-		return activities;
-	};
-
-	// const incrementDate = (date: Date): Date => {
-	// 	date.setDate(date.getDate() + 1);
-
-	// 	return date;
-	// };
-</script>
-
-<details open>
-	<summary>Activity History</summary>
-
-	Days in risk of developing an activity history hole. (days with one activity)
-
-	<p />
-
-	{#if data.user === undefined}
-		Please log in to view this page.
-	{:else}
-		{#await activityHistoryData}
-			Loading ...
-		{:then activities}
-			{#if activities === undefined}
-				Loading ...
-			{:else}
-				<ul>
-					{#each fillMissingDays(activities) as activity}
-						{#if activity.amount === 0}
-							<li>
-								{new Date(activity.date * 1000 + timezoneOffset).toDateString()}
-							</li>
-						{/if}
-					{/each}
-				</ul>
-			{/if}
-		{/await}
-	{/if}
-</details>
-- 
cgit v1.2.3

