Skip to content

Commit

Permalink
🚚 Do not talk about archives anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardstanislas committed Apr 3, 2023
1 parent 3bfc441 commit ee5c88c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/routes/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ export const load = async ({ locals }) => {
return {};
}
const date = getParisDate();
let encryptedJournal = '';
let entries: {
let encryptedTodaysJournal = '';
let journals: {
date: Date;
content: string;
}[] = [];
try {
encryptedJournal = await client.get(keyId, date);
encryptedTodaysJournal = await client.get(keyId, date);
} catch (e) {
console.warn(e);
}
try {
entries = await client.listByKeyId(keyId);
journals = await client.listByKeyId(keyId);
} catch (e) {
console.warn(e);
}
return {
encryptedJournal,
archives: entries
encryptedTodaysJournal,
journals: journals
.map(({ date }) => date)
.filter((date) => date.getTime() !== getParisDate().getTime())
};
Expand Down
13 changes: 7 additions & 6 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import type { PageData } from './$types';
export let data: PageData;
$: if ($keyPair && data.encryptedJournal) {
initJournalFromEncryptedContent(data.encryptedJournal, $keyPair.privateKey);
$: if ($keyPair && data.encryptedTodaysJournal) {
initJournalFromEncryptedContent(data.encryptedTodaysJournal, $keyPair.privateKey);
}
$: base64EncodedJournal = browser
Expand All @@ -17,12 +17,13 @@

<p>Archives</p>
<ul>
{#each data.archives || [] as archive}
{#each data.journals || [] as journalDate}
<li>
<a
href={`archives/${
archive.getUTCMonth() + 1
}/${archive.getUTCDate()}/${archive.getUTCFullYear()}`}>{archive.toLocaleDateString()}</a
href={`${
journalDate.getUTCMonth() + 1
}/${journalDate.getUTCDate()}/${journalDate.getUTCFullYear()}`}
>{journalDate.toLocaleDateString()}</a
>
</li>
{/each}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const load = async ({ params, locals }) => {
}
const date = getDateFromDayMonthYear(day, month, year);
if (date.getTime() === getParisDate().getTime()) {
throw error(422, "You cannot access today's archive");
throw error(422, "You cannot access today's journal");
}
try {
const encryptedArchive = await client.get(keyId, date);
return { encryptedArchive };
const encryptedJournal = await client.get(keyId, date);
return { encryptedJournal };
} catch (e) {
console.warn(e);
throw error(404, 'Not found');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import { initJournalFromEncryptedContent, journal } from '$lib/stores/journal';
export let data: PageData;
$: if ($keyPair && data.encryptedArchive) {
initJournalFromEncryptedContent(data.encryptedArchive, $keyPair.privateKey);
$: if ($keyPair && data.encryptedJournal) {
initJournalFromEncryptedContent(data.encryptedJournal, $keyPair.privateKey);
}
</script>

<div>{$journal}</div>
<a href="/">Back to today's journal</a>

1 comment on commit ee5c88c

@vercel
Copy link

@vercel vercel bot commented on ee5c88c Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.