mirror of
https://github.com/DocNR/POWR.git
synced 2025-04-23 01:01:27 +00:00
Update RelayInitializer and SocialFeedService to use transaction lock
This commit is contained in:
parent
4e5ca9fcaf
commit
b5bf32d10f
@ -7,6 +7,7 @@ import { useConnectivity } from '@/lib/db/services/ConnectivityService';
|
|||||||
import { ConnectivityService } from '@/lib/db/services/ConnectivityService';
|
import { ConnectivityService } from '@/lib/db/services/ConnectivityService';
|
||||||
import { profileImageCache } from '@/lib/db/services/ProfileImageCache';
|
import { profileImageCache } from '@/lib/db/services/ProfileImageCache';
|
||||||
import { getSocialFeedCache } from '@/lib/db/services/SocialFeedCache';
|
import { getSocialFeedCache } from '@/lib/db/services/SocialFeedCache';
|
||||||
|
import { getContactCacheService } from '@/lib/db/services/ContactCacheService';
|
||||||
import { useDatabase } from '@/components/DatabaseProvider';
|
import { useDatabase } from '@/components/DatabaseProvider';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,8 +27,15 @@ export default function RelayInitializer() {
|
|||||||
console.log('[RelayInitializer] Setting NDK instance in ProfileImageCache');
|
console.log('[RelayInitializer] Setting NDK instance in ProfileImageCache');
|
||||||
profileImageCache.setNDK(ndk);
|
profileImageCache.setNDK(ndk);
|
||||||
|
|
||||||
// Initialize SocialFeedCache with NDK instance
|
// Initialize caches with NDK instance
|
||||||
if (db) {
|
if (db) {
|
||||||
|
// Initialize ContactCacheService
|
||||||
|
try {
|
||||||
|
getContactCacheService(db);
|
||||||
|
console.log('[RelayInitializer] ContactCacheService initialized');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[RelayInitializer] Error initializing ContactCacheService:', error);
|
||||||
|
}
|
||||||
// Maximum number of retry attempts
|
// Maximum number of retry attempts
|
||||||
const MAX_RETRIES = 3;
|
const MAX_RETRIES = 3;
|
||||||
|
|
||||||
|
@ -165,12 +165,13 @@ export class SocialFeedService {
|
|||||||
} else if (feedType === 'following') {
|
} else if (feedType === 'following') {
|
||||||
// Following feed: Show content from followed users
|
// Following feed: Show content from followed users
|
||||||
if (!Array.isArray(authors) || authors.length === 0) {
|
if (!Array.isArray(authors) || authors.length === 0) {
|
||||||
console.error('[SocialFeedService] Following feed requires authors');
|
// Initial load often has no contacts yet - this is normal
|
||||||
|
console.log('[SocialFeedService] No contacts available for following feed yet, using fallback');
|
||||||
|
|
||||||
// For following feed, if no authors provided, use the POWR_PUBKEY_HEX as fallback
|
// For following feed, if no authors provided, use the POWR_PUBKEY_HEX as fallback
|
||||||
// This ensures at least some content is shown
|
// This ensures at least some content is shown
|
||||||
if (POWR_PUBKEY_HEX) {
|
if (POWR_PUBKEY_HEX) {
|
||||||
console.log('[SocialFeedService] Using POWR account as fallback for Following feed');
|
console.log('[SocialFeedService] Using POWR account as fallback for initial Following feed load');
|
||||||
const fallbackAuthors = [POWR_PUBKEY_HEX];
|
const fallbackAuthors = [POWR_PUBKEY_HEX];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user