feat(ui): add new tag to changelogs

This commit is contained in:
max_richter 2021-03-16 16:05:35 +01:00
parent 312d15a296
commit 396c2c4b4d
3 changed files with 23 additions and 11 deletions

View File

@ -1,7 +1,10 @@
<script lang="ts">
export let commit: Commit;
export let isNew = false;
</script>
<p>
{@html isNew ? "<b>[NEW]</b>" : ""}
{commit.subject}
</p>

View File

@ -23,7 +23,7 @@ import { commitStore, route } from "stores";
}
});
if (newCommits.length > 2) {
if (newCommits.length > 1) {
if (window.location.hash !== "#changelog") {
if ((await Toast.ask(`There are <b>${newCommits.length}</b> updates. Do you want to see them?`, ["yes", "no"])) === "yes") {
route.set("changelog")

View File

@ -2,12 +2,7 @@
import Commit from "components/Changelog/Commit.svelte";
import { commitStore, route } from "stores";
$: if ($commitStore.length) {
localStorage.setItem(
"currentCommit",
$commitStore[$commitStore.length - 1].id
);
}
let currentCommit = localStorage.getItem("currentCommit");
$: commits =
$commitStore.length &&
@ -24,11 +19,13 @@
return commit;
});
$: if (commits.length) {
localStorage.setItem("currentCommit", commits[0].id);
}
let day = $commitStore.length && new Date($commitStore[0].date).getDay();
const checkDate = (commit) => {
console.log(commit);
const d = new Date(commit.date);
if (d.getDay() != day) {
day = d.getDay();
@ -37,6 +34,19 @@
return false;
};
let isFound = false;
const checkIfNew = (commitId) => {
console.log(commitId, currentCommit);
if (isFound) return false;
if (commitId === currentCommit) {
isFound = true;
return false;
}
return true;
};
const prettyDate = (date) => {
return new Date(date).toLocaleDateString();
};
@ -52,8 +62,7 @@
{prettyDate(commit.date)}
</h3>
{/if}
<Commit {commit} />
<Commit {commit} isNew={checkIfNew(commit.id)} />
{/each}
</main>