chore(monorepo/client): various type errors

This commit is contained in:
Elian Doran 2025-04-18 11:00:48 +03:00
parent 13a6fefaa2
commit fe87889ee7
No known key found for this signature in database
5 changed files with 11 additions and 6 deletions

View File

@ -2,7 +2,7 @@ import options from "./options.js";
import i18next from "i18next";
import i18nextHttpBackend from "i18next-http-backend";
import server from "./server.js";
import type { Locale } from "../../../services/i18n.js";
import type { Locale } from "@triliumnext/commons";
let locales: Locale[] | null;

View File

@ -35,7 +35,7 @@ export default class BookmarkSwitchWidget extends SwitchWidget {
async toggle(state: boolean | null | undefined) {
const resp = await server.put<Response>(`notes/${this.noteId}/toggle-in-parent/_lbBookmarks/${!!state}`);
if (!resp.success) {
if (!resp.success && "message" in resp) {
toastService.showError(resp.message);
}
}

View File

@ -8,9 +8,9 @@ import appContext from "../../components/app_context.js";
import openService from "../../services/open.js";
import utils from "../../services/utils.js";
import { Dropdown } from "bootstrap";
import type attachmentsApiRoute from "../../../../routes/api/attachments.js";
import type FAttachment from "../../entities/fattachment.js";
import type AttachmentDetailWidget from "../attachment_detail.js";
import { NoteRow } from "@triliumnext/commons";
const TPL = /*html*/`
<div class="dropdown attachment-actions">
@ -81,6 +81,11 @@ const TPL = /*html*/`
<input type="file" class="attachment-upload-new-revision-input" style="display: none">
</div>`;
// TODO: Deduplicate
interface AttachmentResponse {
note: NoteRow;
}
export default class AttachmentActionsWidget extends BasicWidget {
$uploadNewRevisionInput!: JQuery<HTMLInputElement>;
attachment: FAttachment;
@ -168,7 +173,7 @@ export default class AttachmentActionsWidget extends BasicWidget {
return;
}
const { note: newNote } = await server.post<ReturnType<typeof attachmentsApiRoute.convertAttachmentToNote>>(`attachments/${this.attachmentId}/convert-to-note`);
const { note: newNote } = await server.post<AttachmentResponse>(`attachments/${this.attachmentId}/convert-to-note`);
toastService.showMessage(t("attachments_actions.convert_success", { title: this.attachment.title }));
await ws.waitForMaxKnownEntityChangeId();
await appContext.tabManager.getActiveContext()?.setNote(newNote.noteId);

View File

@ -207,7 +207,7 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
async getIconToCountMap() {
if (!this.iconToCountCache) {
this.iconToCountCache = server.get<typeof this.iconToCountCache>("other/icon-usage");
this.iconToCountCache = server.get<IconToCountCache>("other/icon-usage");
setTimeout(() => (this.iconToCountCache = null), 20000); // invalidate cache after 20 seconds
}

View File

@ -5,7 +5,7 @@ import { t } from "i18next";
import type { EventData } from "../components/app_context.js";
import type FNote from "../entities/fnote.js";
import attributes from "../services/attributes.js";
import type { Locale } from "../../../services/i18n.js";
import type { Locale } from "@triliumnext/commons";
import options from "../services/options.js";
import appContext from "../components/app_context.js";