fix(idaa): gate jitsi report load and restore data store fallback

This commit is contained in:
Scott Idem
2026-05-01 13:45:24 -04:00
parent e7b6045580
commit d5e5cb7ada
3 changed files with 39 additions and 49 deletions

View File

@@ -36,8 +36,9 @@ export async function get_data_store({
const headers: key_val = {};
if (no_account_id) {
// This token allows bypassing the mandatory account_id requirement for global defaults
headers['x-no-account-id-token'] = 'Nothing to See Here';
// Use the standard bypass header understood by get_object so the
// request can actually fall back to global defaults.
headers['x-no-account-id'] = 'Nothing to See Here';
}
return await get_object({

View File

@@ -1,6 +1,9 @@
<script lang="ts">
import { untrack } from 'svelte';
import { ae_util } from '$lib/ae_utils/ae_utils';
import { ae_loc } from '$lib/stores/ae_stores';
import { load_jitsi_report } from '$lib/ae_reports/reports_functions';
import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { idaa_loc } from '$lib/stores/ae_idaa_stores';
import JitsiUrlBuilder from './ae_idaa_comp__jitsi_url_builder.svelte';
interface MeetingEvent {
@@ -24,29 +27,42 @@ interface MeetingReport {
events: MeetingEvent[];
}
interface Props {
data: { streamed: { meetings: Promise<MeetingReport[]> } };
}
let { data }: Props = $props();
// --- Data state ---
// Resolve the streamed promise into reactive state so we can filter and export it.
let meetings_all = $state<MeetingReport[]>([]);
let meetings_loading = $state(true);
let meetings_error = $state<string | null>(null);
let meetings_load_started = $state(false);
$effect(() => {
if (meetings_load_started) return;
if (!$idaa_loc.novi_verified && !$ae_loc.trusted_access) return;
const api_cfg = $ae_api;
const account_id = $ae_loc.account_id;
if (!api_cfg || !account_id) return;
meetings_load_started = true;
meetings_loading = true;
meetings_error = null;
data.streamed.meetings
.then((m: MeetingReport[]) => {
meetings_all = m ?? [];
meetings_loading = false;
untrack(() => {
void load_jitsi_report({
api_cfg,
account_id,
log_lvl: 1
})
.catch((err: Error) => {
meetings_error = err.message;
meetings_loading = false;
});
.then((m: MeetingReport[]) => {
meetings_all = m ?? [];
meetings_loading = false;
})
.catch((err: unknown) => {
meetings_error =
err instanceof Error ? err.message : String(err);
meetings_loading = false;
});
});
});
// --- Filter state ---
@@ -357,7 +373,7 @@ function export_json() {
</div>
<div
class="bg-surface-100-900 border-surface-200-800 rounded-xl border p-3 text-center">
<div class="font-mono text-2xl text-lg font-bold">
<div class="font-mono text-2xl font-bold">
{summary.avg_duration}
</div>
<div class="text-xs tracking-wide uppercase opacity-40">
@@ -366,7 +382,7 @@ function export_json() {
</div>
<div
class="bg-surface-100-900 border-surface-200-800 rounded-xl border p-3 text-center">
<div class="font-mono text-2xl text-lg font-bold">
<div class="font-mono text-2xl font-bold">
{summary.total_duration}
</div>
<div class="text-xs tracking-wide uppercase opacity-40">

View File

@@ -1,34 +1,7 @@
import type { PageLoad } from './$types';
import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { load_jitsi_report } from '$lib/ae_reports/reports_functions';
import { get } from 'svelte/store';
export const load: PageLoad = async ({ fetch }) => {
console.log('*** /idaa/jitsi_reports/+page.ts ***');
const api_cfg = get(ae_api);
const account_id = get(ae_loc)?.account_id;
if (!api_cfg || !account_id) {
console.error(
'API config or Account ID not available for loading Jitsi reports.'
);
return {
streamed: {
meetings: Promise.resolve([])
}
};
}
const meetings_promise = load_jitsi_report({
api_cfg,
account_id,
log_lvl: 1
});
return {
streamed: {
meetings: meetings_promise
}
};
// Keep this load function thin. IDAA report data is fetched in +page.svelte
// after auth, because +page.ts runs before layout effects and during prefetch.
export const load: PageLoad = async () => {
return {};
};