better loading

This commit is contained in:
Ämin Baumeler 2025-06-10 14:51:43 +02:00
parent 5d8b913d78
commit 12bde0fa39
2 changed files with 23 additions and 8 deletions

View File

@ -13,6 +13,7 @@ function slice(start, stop, desc) {
return CYAN start OFF " -- " CYAN stop OFF ": " desc return CYAN start OFF " -- " CYAN stop OFF ": " desc
} }
function hrline(hour) { function hrline(hour) {
hour = hour < 10 ? "0"hour : hour
print hour, "", "", "", FAINT hour ":00 ----------------------" OFF print hour, "", "", "", FAINT hour ":00 ----------------------" OFF
} }
function hrlines(start, stop, h, starth, stoph, tmp, i) { function hrlines(start, stop, h, starth, stoph, tmp, i) {

View File

@ -293,19 +293,28 @@ __edit() {
filenew="$filetmp.ics" filenew="$filetmp.ics"
awk "$AWK_UPDATE" "$filetmp" "$fpath" >"$filenew" awk "$AWK_UPDATE" "$filetmp" "$fpath" >"$filenew"
mv "$filenew" "$fpath" mv "$filenew" "$fpath"
__refresh_data
fi fi
rm "$filetmp" rm "$filetmp"
} }
if [ -z "${APPROX_DATA_FILE:-}" ]; then __refresh_data() {
if [ -n "${APPROX_DATA_FILE:-}" ]; then
rm "$APPROX_DATA_FILE"
fi
if [ -n "${WEEKLY_DATA_FILE:-}" ]; then
rm "$WEEKLY_DATA_FILE"
fi
APPROX_DATA_FILE=$(mktemp) APPROX_DATA_FILE=$(mktemp)
__load_approx_data >"$APPROX_DATA_FILE" __load_approx_data >"$APPROX_DATA_FILE"
export APPROX_DATA_FILE export APPROX_DATA_FILE
fi
if [ -z "${WEEKLY_DATA_FILE:-}" ]; then
WEEKLY_DATA_FILE=$(mktemp) WEEKLY_DATA_FILE=$(mktemp)
__load_weeks >"$WEEKLY_DATA_FILE" __load_weeks >"$WEEKLY_DATA_FILE"
export WEEKLY_DATA_FILE export WEEKLY_DATA_FILE
}
if [ -z "${APPROX_DATA_FILE:-}" ]; then
__refresh_data
fi fi
if [ "${1:-}" = "--help" ]; then if [ "${1:-}" = "--help" ]; then
@ -314,9 +323,16 @@ if [ "${1:-}" = "--help" ]; then
echo "You may specify at most one option." echo "You may specify at most one option."
echo " --help Show this help and exit" echo " --help Show this help and exit"
echo " --new Create new entry" echo " --new Create new entry"
echo " --today Show today's appointments"
echo " --day <day> Show appointments of specified day"
echo " --date <date> Show week of specified date"
exit exit
fi fi
if [ "${1:-}" = "--today" ]; then
exec $0 --day "today"
fi
if [ "${1:-}" = "--new" ]; then if [ "${1:-}" = "--new" ]; then
collection=$(echo "$COLLECTION_LABELS" | tr ';' '\n' | $FZF --delimiter='=' --with-nth=2 --accept-nth=1) collection=$(echo "$COLLECTION_LABELS" | tr ';' '\n' | $FZF --delimiter='=' --with-nth=2 --accept-nth=1)
fpath="" fpath=""
@ -343,6 +359,7 @@ if [ "${1:-}" = "--new" ]; then
filenew="$filetmp.ics" filenew="$filetmp.ics"
awk -v uid="$uuid" "$AWK_NEW" "$filetmp" >"$filenew" awk -v uid="$uuid" "$AWK_NEW" "$filetmp" >"$filenew"
mv "$filenew" "$fpath" mv "$filenew" "$fpath"
__refresh_data
fi fi
rm "$filetmp" rm "$filetmp"
fi fi
@ -386,16 +403,13 @@ if [ "${1:-}" = "--delete" ]; then
esac esac
done done
fi fi
__refresh_data
exec $0 --day "$DISPLAY_DATE" exec $0 --day "$DISPLAY_DATE"
fi fi
if [ "${1:-}" = "--day-reload" ]; then
__show_day
exit
fi
if [ "${1:-}" = "--day" ]; then if [ "${1:-}" = "--day" ]; then
DISPLAY_DATE="$2" DISPLAY_DATE="$2"
export DISPLAY_DATE
selection=$( selection=$(
__show_day | __show_day |
$FZF \ $FZF \