client-ts: Port services/protected_session_holder

This commit is contained in:
Elian Doran 2024-07-25 00:27:50 +03:00
parent cf57819b22
commit 65563cb29e
No known key found for this signature in database
3 changed files with 4 additions and 2 deletions

View File

@ -1,3 +1,4 @@
import FNote from "../entities/fnote.js";
import server from "./server.js"; import server from "./server.js";
function enableProtectedSession() { function enableProtectedSession() {
@ -20,7 +21,7 @@ async function touchProtectedSession() {
} }
} }
function touchProtectedSessionIfNecessary(note) { function touchProtectedSessionIfNecessary(note: FNote) {
if (note && note.isProtected && isProtectedSessionAvailable()) { if (note && note.isProtected && isProtectedSessionAvailable()) {
touchProtectedSession(); touchProtectedSession();
} }

View File

@ -58,7 +58,7 @@ async function get<T>(url: string, componentId?: string) {
return await call<T>('GET', url, componentId); return await call<T>('GET', url, componentId);
} }
async function post<T>(url: string, data: unknown, componentId?: string) { async function post<T>(url: string, data?: unknown, componentId?: string) {
return await call<T>('POST', url, componentId, { data }); return await call<T>('POST', url, componentId, { data });
} }

View File

@ -24,6 +24,7 @@ interface CustomGlobals {
componentId: string; componentId: string;
csrfToken: string; csrfToken: string;
baseApiUrl: string; baseApiUrl: string;
isProtectedSessionAvailable: boolean;
} }
type RequireMethod = (moduleName: string) => any; type RequireMethod = (moduleName: string) => any;