1
Fork 0
mirror of https://github.com/Steffo99/todocolors.git synced 2024-10-16 07:17:28 +00:00

Compare commits

...

7 commits

7 changed files with 53 additions and 37 deletions

View file

@ -6,7 +6,7 @@
"display": "standalone",
"theme_color": "#0d193b",
"background_color": "#0c193b",
"description": "Self-hostable multiplayer todo app",
"description": "Multiplayer todo app",
"categories": ["productivity"],
"icons": [
{

View file

@ -4,9 +4,15 @@ import {ICON_DEFAULT, ICON_GLYPH_RE} from "@/app/[lang]/board/[board]/(page)/(ed
import {IMPORTANCE_GLYPH_RE} from "@/app/[lang]/board/[board]/(page)/(edit)/taskImportance"
import {default as dateParser} from "any-date-parser"
// ahhh i love typescript shenanigans
// @ts-ignore
const DATE_FROM_STRING = dateParser.fromString;
type Attempt = {
year?: number,
month?: number,
day?: number,
hour?: number,
minute?: number,
second?: number,
millisecond?: number,
}
const VALUE_TO_TASK_IMPORTANCE = {
"1": TaskImportance.Highest,
@ -23,10 +29,23 @@ export function convertSTT(text: string, lang: string): Task {
const importance: TaskImportance = VALUE_TO_TASK_IMPORTANCE[importanceMatch?.[1]?.trim() as "1"|"2"|"3"|"4"|"5" ?? "3"]
const icon: string = iconMatch?.[1]?.trim() ?? ICON_DEFAULT
const now = new Date()
const deadlineGroup: string | undefined = deadlineMatch?.[1]?.trim()
const deadlineDate: Date | undefined = deadlineGroup === undefined ? undefined : DATE_FROM_STRING(deadlineGroup, lang) ?? undefined
const deadlineAttempt: Attempt | undefined = deadlineGroup === undefined ? undefined : dateParser.attempt(deadlineGroup, lang) ?? undefined
const deadlineDate: Date | undefined = deadlineAttempt === undefined ? undefined : new Date(
deadlineAttempt.year ?? now.getFullYear(),
(deadlineAttempt.month ?? (now.getMonth() + 1)) - 1,
deadlineAttempt.day ?? now.getDate(),
deadlineAttempt.hour ?? now.getHours(),
deadlineAttempt.minute ?? now.getMinutes(),
deadlineAttempt.second ?? now.getSeconds(),
deadlineAttempt.millisecond ?? now.getMilliseconds(),
)
const deadline: number | null = (deadlineDate?.getTime?.()) ?? null
console.debug("[convertSTT]", "\ngroup:", deadlineGroup, "\ndate:", deadlineDate, "\ntimestamp:", deadline)
// TODO: Splice so the regexes aren't executed twice
text = text.replace(IMPORTANCE_GLYPH_RE, "")
text = text.replace(ICON_GLYPH_RE, "")

View file

@ -16,11 +16,11 @@ type TaskIconProps = {
}
const STATUS_TO_PREFIX: {[t in TaskSimplifiedStatus]: IconPack} = {
[TaskSimplifiedStatus.Unfinished]: fal,
[TaskSimplifiedStatus.InProgress]: far,
[TaskSimplifiedStatus.Complete]: fas,
[TaskSimplifiedStatus.Journaled]: fas,
[TaskSimplifiedStatus.NonExistent]: far,
[TaskSimplifiedStatus.Unfinished]: fas,
[TaskSimplifiedStatus.InProgress]: fas,
[TaskSimplifiedStatus.Complete]: fal,
[TaskSimplifiedStatus.Journaled]: far,
[TaskSimplifiedStatus.NonExistent]: fas,
}
export function TaskIconComponent({className, title, icon, status, onInteract}: TaskIconProps) {
@ -31,6 +31,7 @@ export function TaskIconComponent({className, title, icon, status, onInteract}:
className={cn({
[style.taskIconComponent]: true,
[style.taskIconComponentClickable]: clickable,
"fade": status === TaskSimplifiedStatus.Complete,
}, className)}
type={"button"}
title={title}

View file

@ -15,8 +15,8 @@ const TASK_IMPORTANCE_TO_VALUE = {
const TASK_STATUS_TO_VALUE = {
"Journaled": 3,
"Complete": 2,
"InProgress": 1,
"Unfinished": 0,
"InProgress": 0,
"Unfinished": 1,
}
export const GROUPING_MODE_TO_GROUP_SORTER_FUNCTION = {

View file

@ -25,6 +25,22 @@ export function useBoardLayoutEditor() {
GroupingMode.Journal,
])
const sortingHook = useCycler(useLocalStorage<number | undefined>(localStorageKeySorting, undefined), [
[
SortingMode.ByDeadline,
SortingMode.ByImportance,
SortingMode.ByStatus,
SortingMode.ByText,
SortingMode.ByIcon,
SortingMode.ByCreation,
],
[
SortingMode.ByImportance,
SortingMode.ByDeadline,
SortingMode.ByStatus,
SortingMode.ByText,
SortingMode.ByIcon,
SortingMode.ByCreation,
],
[
SortingMode.ByStatus,
SortingMode.ByDeadline,
@ -40,35 +56,6 @@ export function useBoardLayoutEditor() {
SortingMode.ByText,
SortingMode.ByIcon,
SortingMode.ByCreation,
],
[
SortingMode.ByStatus,
SortingMode.ByText,
SortingMode.ByIcon,
SortingMode.ByCreation,
],
[
SortingMode.ByStatus,
SortingMode.ByCreation,
],
[
SortingMode.ByDeadline,
SortingMode.ByImportance,
SortingMode.ByText,
SortingMode.ByIcon,
SortingMode.ByCreation,
],
[
SortingMode.ByImportance,
SortingMode.ByDeadline,
SortingMode.ByText,
SortingMode.ByIcon,
SortingMode.ByCreation,
],
[
SortingMode.ByText,
SortingMode.ByIcon,
SortingMode.ByCreation,
],
[
SortingMode.ByCreation,

8
todocolors.iml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -37,8 +37,9 @@ async fn main() {
)
);
log::info!("Starting web server!");
axum::Server::bind(&std::net::SocketAddr::from_str(&config::AXUM_HOST).expect("AXUM_HOST to be a valid SocketAddr"))
let host = std::net::SocketAddr::from_str(&config::AXUM_HOST).expect("AXUM_HOST to be a valid SocketAddr");
log::info!("Starting web server on: {host:?}");
axum::Server::bind(&host)
.serve(router.into_make_service())
.await
.expect("to be able to run the Axum server");