mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2026-01-10 07:03:04 +00:00
↩️ return type annotations
This commit is contained in:
parent
804ad3f92f
commit
4bab74b852
15 changed files with 48 additions and 48 deletions
|
|
@ -23,7 +23,7 @@ const modal_visible = ref(false);
|
|||
const is_busy = ref(false);
|
||||
const store = advent22Store();
|
||||
|
||||
function on_click() {
|
||||
function on_click(): void {
|
||||
if (store.is_admin) {
|
||||
store.logout();
|
||||
} else {
|
||||
|
|
@ -33,7 +33,7 @@ function on_click() {
|
|||
}
|
||||
}
|
||||
|
||||
function on_submit(creds: Credentials) {
|
||||
async function on_submit(creds: Credentials): Promise<void> {
|
||||
modal_visible.value = false;
|
||||
|
||||
store
|
||||
|
|
@ -42,7 +42,7 @@ function on_submit(creds: Credentials) {
|
|||
.finally(() => (is_busy.value = false));
|
||||
}
|
||||
|
||||
function on_cancel() {
|
||||
function on_cancel(): void {
|
||||
modal_visible.value = false;
|
||||
is_busy.value = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ let modal: HMultiModal | undefined;
|
|||
let toast: HBulmaToast | undefined;
|
||||
let toast_timeout: number | undefined;
|
||||
|
||||
function on_modal_handle(handle: HMultiModal) {
|
||||
function on_modal_handle(handle: HMultiModal): void {
|
||||
modal = handle;
|
||||
}
|
||||
|
||||
function on_toast_handle(handle: HBulmaToast) {
|
||||
function on_toast_handle(handle: HBulmaToast): void {
|
||||
toast = handle;
|
||||
|
||||
if (store.is_touch_device) return;
|
||||
|
|
@ -90,7 +90,7 @@ function on_toast_handle(handle: HBulmaToast) {
|
|||
});
|
||||
}
|
||||
|
||||
async function door_click(day: number) {
|
||||
async function door_click(day: number): Promise<void> {
|
||||
window.clearTimeout(toast_timeout);
|
||||
toast?.hide();
|
||||
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ const emit = defineEmits<{
|
|||
(event: "handle", handle: HMultiModal): void;
|
||||
}>();
|
||||
|
||||
function hide() {
|
||||
function hide(): void {
|
||||
state.value = { show: "none" };
|
||||
}
|
||||
|
||||
function dismiss() {
|
||||
function dismiss(): void {
|
||||
if (state.value.show !== "loading") {
|
||||
hide();
|
||||
}
|
||||
|
|
@ -58,10 +58,10 @@ function dismiss() {
|
|||
|
||||
onMounted(() => {
|
||||
emit("handle", {
|
||||
show_image(src: string, caption: string = "") {
|
||||
show_image(src: string, caption: string = ""): void {
|
||||
state.value = { show: "image", src: src, caption: caption };
|
||||
},
|
||||
show_loading() {
|
||||
show_loading(): void {
|
||||
state.value = { show: "loading" };
|
||||
},
|
||||
hide,
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ const day_data = ref<Record<number, { part: string; image_name: string }>>({});
|
|||
|
||||
let modal: HMultiModal | undefined;
|
||||
|
||||
function on_modal_handle(handle: HMultiModal) {
|
||||
function on_modal_handle(handle: HMultiModal): void {
|
||||
modal = handle;
|
||||
}
|
||||
|
||||
async function on_open() {
|
||||
async function on_open(): Promise<void> {
|
||||
const [day_parts, day_image_names] = await Promise.all([
|
||||
API.request<NumStrDict>("admin/day_parts"),
|
||||
API.request<NumStrDict>("admin/day_image_names"),
|
||||
|
|
@ -86,7 +86,7 @@ async function on_open() {
|
|||
});
|
||||
}
|
||||
|
||||
async function door_click(day: number) {
|
||||
async function door_click(day: number): Promise<void> {
|
||||
if (modal === undefined) return;
|
||||
modal.show_loading();
|
||||
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ function fmt_puzzle_date(name: keyof AdminConfigModel["puzzle"]): string {
|
|||
return DateTime.fromISO(iso_date).toLocaleString(DateTime.DATE_SHORT);
|
||||
}
|
||||
|
||||
async function on_open() {
|
||||
async function on_open(): Promise<void> {
|
||||
const [store_update, new_admin_config_model, new_doors] = await Promise.all([
|
||||
store.update(),
|
||||
API.request<AdminConfigModel>("admin/config_model"),
|
||||
|
|
@ -259,7 +259,7 @@ async function on_open() {
|
|||
doors.value = new_doors;
|
||||
}
|
||||
|
||||
async function load_dav_credentials() {
|
||||
async function load_dav_credentials(): Promise<void> {
|
||||
try {
|
||||
dav_credentials.value = await API.request<Credentials>(
|
||||
"admin/dav_credentials",
|
||||
|
|
@ -267,7 +267,7 @@ async function load_dav_credentials() {
|
|||
} catch {}
|
||||
}
|
||||
|
||||
async function load_ui_credentials() {
|
||||
async function load_ui_credentials(): Promise<void> {
|
||||
try {
|
||||
ui_credentials.value = await API.request<Credentials>(
|
||||
"admin/ui_credentials",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
:disabled="current_step === 0"
|
||||
class="level-item is-link"
|
||||
@click="current_step--"
|
||||
:icon="['fas', 'fa-backward']"
|
||||
:icon="['fas', 'fa-backward']"
|
||||
/>
|
||||
|
||||
<BulmaBreadcrumbs
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
:disabled="current_step === 2"
|
||||
class="level-item is-link"
|
||||
@click="current_step++"
|
||||
:icon="['fas', 'fa-forward']"
|
||||
:icon="['fas', 'fa-forward']"
|
||||
/>
|
||||
</nav>
|
||||
|
||||
|
|
@ -47,20 +47,20 @@
|
|||
<BulmaButton
|
||||
class="card-footer-item is-danger"
|
||||
@click="on_download"
|
||||
:icon="['fas', 'fa-cloud-arrow-down']"
|
||||
:icon="['fas', 'fa-cloud-arrow-down']"
|
||||
:busy="loading_doors"
|
||||
text="Laden"
|
||||
/>
|
||||
<BulmaButton
|
||||
class="card-footer-item is-warning"
|
||||
@click="on_discard"
|
||||
:icon="['fas', 'fa-trash']"
|
||||
:icon="['fas', 'fa-trash']"
|
||||
text="Löschen"
|
||||
/>
|
||||
<BulmaButton
|
||||
class="card-footer-item is-success"
|
||||
@click="on_upload"
|
||||
:icon="['fas', 'fa-cloud-arrow-up']"
|
||||
:icon="['fas', 'fa-cloud-arrow-up']"
|
||||
:busy="saving_doors"
|
||||
text="Speichern"
|
||||
/>
|
||||
|
|
@ -95,7 +95,7 @@ const current_step = ref(0);
|
|||
const loading_doors = ref(false);
|
||||
const saving_doors = ref(false);
|
||||
|
||||
async function load_doors() {
|
||||
async function load_doors(): Promise<void> {
|
||||
try {
|
||||
const data = await API.request<DoorSaved[]>("admin/doors");
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ async function load_doors() {
|
|||
}
|
||||
}
|
||||
|
||||
async function save_doors() {
|
||||
async function save_doors(): Promise<void> {
|
||||
try {
|
||||
const data: DoorSaved[] = [];
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ async function save_doors() {
|
|||
}
|
||||
}
|
||||
|
||||
async function on_download() {
|
||||
async function on_download(): Promise<void> {
|
||||
if (confirm("Aktuelle Änderungen verwerfen und Status vom Server laden?")) {
|
||||
loading_doors.value = true;
|
||||
|
||||
|
|
@ -146,14 +146,14 @@ async function on_download() {
|
|||
}
|
||||
}
|
||||
|
||||
function on_discard() {
|
||||
function on_discard(): void {
|
||||
if (confirm("Alle Türchen löschen? (nur lokal)")) {
|
||||
// empty `doors` array
|
||||
doors.value.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function on_upload() {
|
||||
async function on_upload(): Promise<void> {
|
||||
if (confirm("Aktuelle Änderungen an den Server schicken?")) {
|
||||
saving_doors.value = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ const props = withDefaults(
|
|||
const state = ref<"closed" | "loading" | "ok" | "err">("closed");
|
||||
const is_open = computed(() => state.value !== "closed");
|
||||
|
||||
async function toggle() {
|
||||
async function toggle(): Promise<void> {
|
||||
if (is_open.value) {
|
||||
state.value = "closed";
|
||||
} else {
|
||||
|
|
@ -64,7 +64,7 @@ async function toggle() {
|
|||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
async function load(): Promise<void> {
|
||||
state.value = "loading";
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ const message = useTemplateRef("message");
|
|||
|
||||
onMounted(() =>
|
||||
emit("handle", {
|
||||
show(options: ToastOptions = {}) {
|
||||
show(options: ToastOptions = {}): void {
|
||||
if (message.value === null) return;
|
||||
|
||||
toast({
|
||||
|
|
@ -33,7 +33,7 @@ onMounted(() =>
|
|||
message: message.value,
|
||||
});
|
||||
},
|
||||
hide() {
|
||||
hide(): void {
|
||||
if (message.value === null) return;
|
||||
|
||||
const toast_div = message.value.parentElement;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ const emit = defineEmits<{
|
|||
(event: TCEventType, e: MouseEvent, point: Vector2D): void;
|
||||
}>();
|
||||
|
||||
function transform_mouse_event(event: MouseEvent) {
|
||||
function transform_mouse_event(event: MouseEvent): void {
|
||||
if (!is_tceventtype(event.type)) return;
|
||||
|
||||
emit(event.type, event, get_event_thous(event));
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ function pop_door(point: Vector2D): VueLike<Door> | undefined {
|
|||
return model.value.splice(idx, 1)[0];
|
||||
}
|
||||
|
||||
function draw_start(event: MouseEvent, point: Vector2D) {
|
||||
function draw_start(event: MouseEvent, point: Vector2D): void {
|
||||
if (preview_visible.value) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ function draw_start(event: MouseEvent, point: Vector2D) {
|
|||
state.value = { kind: "drawing" };
|
||||
}
|
||||
|
||||
function draw_finish() {
|
||||
function draw_finish(): void {
|
||||
if (state.value.kind !== "drawing") {
|
||||
return;
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ function draw_finish() {
|
|||
state.value = { kind: "idle" };
|
||||
}
|
||||
|
||||
function drag_start(event: MouseEvent, point: Vector2D) {
|
||||
function drag_start(event: MouseEvent, point: Vector2D): void {
|
||||
if (preview_visible.value) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ function drag_start(event: MouseEvent, point: Vector2D) {
|
|||
state.value = { kind: "dragging", door: drag_door, origin: point };
|
||||
}
|
||||
|
||||
function drag_finish() {
|
||||
function drag_finish(): void {
|
||||
if (state.value.kind !== "dragging") {
|
||||
return;
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ function drag_finish() {
|
|||
state.value = { kind: "idle" };
|
||||
}
|
||||
|
||||
function on_mousemove(event: MouseEvent, point: Vector2D) {
|
||||
function on_mousemove(event: MouseEvent, point: Vector2D): void {
|
||||
if (state.value.kind === "drawing") {
|
||||
preview.value = preview.value.update(undefined, point);
|
||||
} else if (state.value.kind === "dragging") {
|
||||
|
|
@ -113,7 +113,7 @@ function on_mousemove(event: MouseEvent, point: Vector2D) {
|
|||
}
|
||||
}
|
||||
|
||||
function remove_rect(event: MouseEvent, point: Vector2D) {
|
||||
function remove_rect(event: MouseEvent, point: Vector2D): void {
|
||||
if (preview_visible.value) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ const day_input = useTemplateRef("day_input");
|
|||
const day_str = ref("");
|
||||
const editing = ref(false);
|
||||
|
||||
function toggle_editing() {
|
||||
function toggle_editing(): void {
|
||||
day_str.value = String(model.value.day);
|
||||
editing.value = !editing.value;
|
||||
}
|
||||
|
||||
function on_click(event: MouseEvent) {
|
||||
function on_click(event: MouseEvent): void {
|
||||
if (!(event.target instanceof HTMLDivElement)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ function on_click(event: MouseEvent) {
|
|||
toggle_editing();
|
||||
}
|
||||
|
||||
function on_keydown(event: KeyboardEvent) {
|
||||
function on_keydown(event: KeyboardEvent): void {
|
||||
if (!editing.value) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,14 +62,14 @@ export class APIError extends Error {
|
|||
return result();
|
||||
}
|
||||
|
||||
public alert() {
|
||||
public alert(): void {
|
||||
toast({
|
||||
message: this.format(),
|
||||
type: "is-danger",
|
||||
});
|
||||
}
|
||||
|
||||
public static alert(error: unknown) {
|
||||
public static alert(error: unknown): void {
|
||||
new APIError(error, "").alert();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export function unwrap_loading<T>(o: Loading<T>): T {
|
|||
return o;
|
||||
}
|
||||
|
||||
export function wait_for(condition: () => boolean, action: () => void) {
|
||||
export function wait_for(condition: () => boolean, action: () => void): void {
|
||||
const enqueue_action = () => {
|
||||
if (!condition()) {
|
||||
nextTick(enqueue_action);
|
||||
|
|
@ -38,7 +38,7 @@ export function wait_for(condition: () => boolean, action: () => void) {
|
|||
enqueue_action();
|
||||
}
|
||||
|
||||
export function handle_error(error: unknown) {
|
||||
export function handle_error(error: unknown): void {
|
||||
if (error instanceof APIError) {
|
||||
error.alert();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -110,12 +110,12 @@ export const advent22Store = defineStore({
|
|||
return this.is_admin;
|
||||
},
|
||||
|
||||
login(creds: Credentials): Promise<boolean> {
|
||||
async login(creds: Credentials): Promise<boolean> {
|
||||
API.creds = { username: creds[0], password: creds[1] };
|
||||
return this.update_is_admin();
|
||||
return await this.update_is_admin();
|
||||
},
|
||||
|
||||
logout(): Promise<boolean> {
|
||||
logout() {
|
||||
return this.login(["", ""]);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ describe("Rectangle Tests", () => {
|
|||
top: number,
|
||||
width: number,
|
||||
height: number,
|
||||
) {
|
||||
): void {
|
||||
expect(r.left).to.equal(left);
|
||||
expect(r.top).to.equal(top);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue