Skip to content

Commit 9253ccf

Browse files
committed
chatrooms initialized
1 parent b68fc1f commit 9253ccf

File tree

3 files changed

+53
-54
lines changed

3 files changed

+53
-54
lines changed

src/pages/Community.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import { useAuth } from '../utils/auth';
3030
import {
3131
ChatMessage,
3232
ChatRoom,
33-
initializeDefaultChatRooms,
3433
getAvailableRooms,
3534
getRoomMessages,
3635
sendMessage,
@@ -63,7 +62,7 @@ const Community: React.FC = () => {
6362
if (!currentUser) return;
6463

6564
try {
66-
await initializeDefaultChatRooms();
65+
// await initializeDefaultChatRooms();
6766
const rooms = await getAvailableRooms(currentUser.uid, userProfile?.gender);
6867
setChatRooms(rooms);
6968

src/utils/chatService.ts

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -46,63 +46,63 @@ export interface ChatRoom {
4646
};
4747
}
4848

49-
// Create default chat rooms if they don't exist
50-
export const initializeDefaultChatRooms = async () => {
51-
try {
52-
// Check if main chat room exists
53-
const mainRoomRef = doc(db, 'rooms', 'main');
54-
const mainRoomDoc = await getDoc(mainRoomRef);
49+
// // Create default chat rooms if they don't exist
50+
// export const initializeDefaultChatRooms = async () => {
51+
// try {
52+
// // Check if main chat room exists
53+
// const mainRoomRef = doc(db, 'rooms', 'main');
54+
// const mainRoomDoc = await getDoc(mainRoomRef);
5555

56-
if (!mainRoomDoc.exists()) {
57-
// Create main chat room
58-
await setDoc(mainRoomRef, {
59-
name: "Main Chat",
60-
participants: [],
61-
createdAt: serverTimestamp(),
62-
createdBy: 'system',
63-
type: 'main'
64-
});
65-
console.log("Main chat room created");
66-
}
56+
// if (!mainRoomDoc.exists()) {
57+
// // Create main chat room
58+
// await setDoc(mainRoomRef, {
59+
// name: "Main Chat",
60+
// participants: [],
61+
// createdAt: serverTimestamp(),
62+
// createdBy: 'system',
63+
// type: 'main'
64+
// });
65+
// console.log("Main chat room created");
66+
// }
6767

68-
// Check if men's chat room exists
69-
const menRoomRef = doc(db, 'rooms', 'men');
70-
const menRoomDoc = await getDoc(menRoomRef);
68+
// // Check if men's chat room exists
69+
// const menRoomRef = doc(db, 'rooms', 'men');
70+
// const menRoomDoc = await getDoc(menRoomRef);
7171

72-
if (!menRoomDoc.exists()) {
73-
// Create men's chat room
74-
await setDoc(menRoomRef, {
75-
name: "Men's Chat",
76-
participants: [],
77-
createdAt: serverTimestamp(),
78-
createdBy: 'system',
79-
type: 'men'
80-
});
81-
console.log("Men's chat room created");
82-
}
72+
// if (!menRoomDoc.exists()) {
73+
// // Create men's chat room
74+
// await setDoc(menRoomRef, {
75+
// name: "Men's Chat",
76+
// participants: [],
77+
// createdAt: serverTimestamp(),
78+
// createdBy: 'system',
79+
// type: 'men'
80+
// });
81+
// console.log("Men's chat room created");
82+
// }
8383

84-
// Check if women's chat room exists
85-
const womenRoomRef = doc(db, 'rooms', 'women');
86-
const womenRoomDoc = await getDoc(womenRoomRef);
84+
// // Check if women's chat room exists
85+
// const womenRoomRef = doc(db, 'rooms', 'women');
86+
// const womenRoomDoc = await getDoc(womenRoomRef);
8787

88-
if (!womenRoomDoc.exists()) {
89-
// Create women's chat room
90-
await setDoc(womenRoomRef, {
91-
name: "Women's Chat",
92-
participants: [],
93-
createdAt: serverTimestamp(),
94-
createdBy: 'system',
95-
type: 'women'
96-
});
97-
console.log("Women's chat room created");
98-
}
88+
// if (!womenRoomDoc.exists()) {
89+
// // Create women's chat room
90+
// await setDoc(womenRoomRef, {
91+
// name: "Women's Chat",
92+
// participants: [],
93+
// createdAt: serverTimestamp(),
94+
// createdBy: 'system',
95+
// type: 'women'
96+
// });
97+
// console.log("Women's chat room created");
98+
// }
9999

100-
return true;
101-
} catch (error) {
102-
console.error("Error initializing default chat rooms:", error);
103-
return false;
104-
}
105-
};
100+
// return true;
101+
// } catch (error) {
102+
// console.error("Error initializing default chat rooms:", error);
103+
// return false;
104+
// }
105+
// };
106106

107107
// Get available chat rooms for a user based on their gender
108108
export const getAvailableRooms = (userId: string, gender?: string) => {

src/utils/firebase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ export const getJournalEntries = async (userId: string): Promise<JournalEntry[]>
360360

361361
// Convert Firestore data to our interface format and sort by date
362362
return entries
363-
.map((entry: any) => ({
363+
.map((entry) => ({
364364
...entry,
365365
timestamp: entry.timestamp.toDate() // Convert Timestamp to JS Date
366366
}))

0 commit comments

Comments
 (0)