perf: preload events and CalDAV config to avoid empty screens
Add CaldavConfigStore and preloadAppData() to load events (current month) and CalDAV config into stores before dismissing the auth loading spinner. This prevents the brief empty flash when first navigating to Calendar or Settings tabs. Also applies Prettier formatting across codebase.
This commit is contained in:
@@ -25,7 +25,7 @@ export class MongoCaldavRepository implements CaldavRepository {
|
||||
}
|
||||
|
||||
async deleteByUserId(userId: string): Promise<boolean> {
|
||||
const result = await CaldavConfigModel.findOneAndDelete({userId});
|
||||
const result = await CaldavConfigModel.findOneAndDelete({ userId });
|
||||
return result !== null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,10 @@ export class MongoEventRepository implements EventRepository {
|
||||
return events.map((e) => e.toJSON() as unknown as CalendarEvent);
|
||||
}
|
||||
|
||||
async findByCaldavUUID(userId: string, caldavUUID: string): Promise<CalendarEvent | null> {
|
||||
async findByCaldavUUID(
|
||||
userId: string,
|
||||
caldavUUID: string,
|
||||
): Promise<CalendarEvent | null> {
|
||||
const event = await EventModel.findOne({ userId, caldavUUID });
|
||||
if (!event) return null;
|
||||
return event.toJSON() as unknown as CalendarEvent;
|
||||
|
||||
@@ -2,9 +2,7 @@ import mongoose, { Schema, Document, Model } from "mongoose";
|
||||
import { CalendarEvent } from "@calchat/shared";
|
||||
import { IdVirtual } from "./types";
|
||||
|
||||
export interface EventDocument
|
||||
extends Omit<CalendarEvent, "id">,
|
||||
Document {
|
||||
export interface EventDocument extends Omit<CalendarEvent, "id">, Document {
|
||||
toJSON(): CalendarEvent;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user