Minor changes

This commit is contained in:
Noel Maróti
2026-11-29 11:50:17 +01:00
parent c18a8c14ca
commit 34752b446c
3 changed files with 11 additions and 8 deletions

View File

@@ -66,7 +66,7 @@
<div id="content_tint"> <div id="content_tint">
@if (router.url.startsWith("/chat/dm") || router.url.startsWith("/chat/picture")) { @if (router.url.startsWith("/chat/dm") || router.url.startsWith("/chat/picture")) {
<!-- To ensure data is loaded --> <!-- To ensure data is loaded -->
@defer (when serviceManager.chatsStatus() != LoadStatus.loading) { @defer (when cache.contactsState() != LoadState.CLEAN_LOADING) {
<router-outlet /> <router-outlet />
} }
} @else if (router.url.startsWith("/chat/network")) { } @else if (router.url.startsWith("/chat/network")) {

View File

@@ -6,9 +6,9 @@ import {Oimg} from '../elements/oimg/oimg';
import {Router, RouterLink} from '@angular/router'; import {Router, RouterLink} from '@angular/router';
import {TranslatePipe} from '@ngx-translate/core'; import {TranslatePipe} from '@ngx-translate/core';
import {LoadStatus, ServiceManager} from '../../service-manager'; import {LoadStatus, ServiceManager} from '../../service-manager';
import { Contact, createContactWrapper } from 'chatenium-sdk-preview'; import { Contact } from 'chatenium-sdk-preview';
import { CHATENIUM_SDK } from '../../chatenium.token'; import { CHATENIUM_SDK } from '../../chatenium.token';
import { Cache, LoadState } from '../../cache'; import { CacheService, LoadState } from '../../cache';
import { Avatar } from '../elements/avatar/avatar'; import { Avatar } from '../elements/avatar/avatar';
@Component({ @Component({
@@ -21,7 +21,7 @@ export class ContactList implements OnInit {
SDK = inject(CHATENIUM_SDK); SDK = inject(CHATENIUM_SDK);
idb = inject(IndexedDB); idb = inject(IndexedDB);
router = inject(Router); router = inject(Router);
cache = inject(Cache); cache = inject(CacheService);
notification = inject(TuiNotificationService); notification = inject(TuiNotificationService);
serviceManager = inject(ServiceManager); serviceManager = inject(ServiceManager);
breakpoint = inject(TUI_BREAKPOINT); breakpoint = inject(TUI_BREAKPOINT);
@@ -30,8 +30,12 @@ export class ContactList implements OnInit {
if (this.cache.contactsState() != LoadState.LOADED) { if (this.cache.contactsState() != LoadState.LOADED) {
try { try {
const contacts = (await this.idb.getAll('contacts')) as Contact[]; const contacts = (await this.idb.getAll('contacts')) as Contact[];
if (contacts.length > 0) {
this.cache.contacts.set(contacts); this.cache.contacts.set(contacts);
this.cache.contactsState.set(LoadState.CACHE_UPDATING); this.cache.contactsState.set(LoadState.CACHE_UPDATING);
} else {
console.log("Found no contacts in cache")
}
} catch (e) { } catch (e) {
console.warn(`Contacts cache load failed: ${e}. Skipping cache load...`); console.warn(`Contacts cache load failed: ${e}. Skipping cache load...`);
} }
@@ -44,8 +48,8 @@ export class ContactList implements OnInit {
return return
} }
this.cache.contacts.set(data); this.cache.contacts.set(data);
this.cache.contactsState.set(LoadState.LOADED);
console.log(`Successfully fetched ${data.length} contacts`); console.log(`Successfully fetched ${data.length} contacts`);
this.cache.contactsState.set(LoadState.LOADED);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
this.serviceManager.chatsStatus.set(LoadStatus.error); this.serviceManager.chatsStatus.set(LoadStatus.error);

View File

@@ -91,7 +91,6 @@ export class SessionManager {
console.log( console.log(
`Successfully rotated token pair for ID: ${userData.userId} Username: ${userData.username}. This session is now ready to be used.`, `Successfully rotated token pair for ID: ${userData.userId} Username: ${userData.username}. This session is now ready to be used.`,
); );
console.log(data.accessToken)
this.sessionReady.set(true); this.sessionReady.set(true);
} catch (e) { } catch (e) {
console.error(e); console.error(e);