tangled
alpha
login
or
join now
xan.lol
/
flushes.app
forked from
atpota.to/flushes.app
0
fork
atom
The 1st decentralized social network for sharing when you're on the toilet. Post a "flush" today! Powered by the AT Protocol.
0
fork
atom
overview
issues
pulls
pipelines
fix
damedotblog
9 months ago
23cd35d8
16569e6d
+49
-88
1 changed file
expand all
collapse all
unified
split
app
src
app
profile
[handle]
page.tsx
+49
-88
app/src/app/profile/[handle]/page.tsx
···
4
import Link from 'next/link';
5
import { useParams } from 'next/navigation';
6
import styles from './profile.module.css';
7
-
import { sanitizeText } from '@/lib/content-filter';
8
import { formatRelativeTime } from '@/lib/time-utils';
0
0
0
0
0
0
0
9
10
// Types for feed entries
11
interface FlushingEntry {
···
144
});
145
146
if (!recordsResponse.ok) {
147
-
// If first attempt fails, try alternative URL pattern
148
-
const altUrl = `${serviceEndpoint}/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=im.flushing.right.now&limit=100`;
149
-
console.log(`First attempt failed, trying alternative URL: ${altUrl}`);
150
-
151
-
const altResponse = await fetch(altUrl, {
152
-
headers: {
153
-
'Accept': 'application/json'
154
-
}
155
-
});
156
-
157
-
if (!altResponse.ok) {
158
-
throw new Error(`Failed to fetch records: ${altResponse.statusText}`);
159
-
}
160
-
161
-
const recordsData = await altResponse.json();
162
-
console.log('Successfully fetched records with alternative URL');
163
-
164
-
// Process the records
165
-
const userEntries = recordsData.records
166
-
.map((record: any) => {
167
-
const text = record.value.text || '';
168
-
if (containsBannedWords(text)) return null;
169
-
170
-
return {
171
-
id: record.uri,
172
-
uri: record.uri,
173
-
cid: record.cid,
174
-
did: did,
175
-
text: sanitizeText(text),
176
-
emoji: record.value.emoji || '🚽',
177
-
created_at: record.value.createdAt
178
-
};
179
-
})
180
-
.filter((entry: any): entry is FlushingEntry => entry !== null);
181
-
182
-
setEntries(userEntries);
183
-
setTotalCount(userEntries.length);
184
-
185
-
// Calculate emoji stats
186
-
const emojiCounts = new Map<string, number>();
187
-
userEntries.forEach((entry: FlushingEntry) => {
188
-
const emoji = entry.emoji?.trim() || '🚽';
189
-
emojiCounts.set(emoji, (emojiCounts.get(emoji) || 0) + 1);
190
-
});
191
-
192
-
const emojiStats = Array.from(emojiCounts.entries())
193
-
.map(([emoji, count]): EmojiStat => ({ emoji, count }))
194
-
.sort((a, b) => b.count - a.count);
195
-
196
-
setEmojiStats(emojiStats);
197
-
} else {
198
-
const recordsData = await recordsResponse.json();
199
-
console.log('Successfully fetched records');
200
-
201
-
// Process the records
202
-
const userEntries = recordsData.records
203
-
.map((record: any) => {
204
-
const text = record.value.text || '';
205
-
if (containsBannedWords(text)) return null;
206
-
207
-
return {
208
-
id: record.uri,
209
-
uri: record.uri,
210
-
cid: record.cid,
211
-
did: did,
212
-
text: sanitizeText(text),
213
-
emoji: record.value.emoji || '🚽',
214
-
created_at: record.value.createdAt
215
-
};
216
-
})
217
-
.filter((entry: any): entry is FlushingEntry => entry !== null);
218
-
219
-
setEntries(userEntries);
220
-
setTotalCount(userEntries.length);
221
-
222
-
// Calculate emoji stats
223
-
const emojiCounts = new Map<string, number>();
224
-
userEntries.forEach((entry: FlushingEntry) => {
225
-
const emoji = entry.emoji?.trim() || '🚽';
226
-
emojiCounts.set(emoji, (emojiCounts.get(emoji) || 0) + 1);
227
-
});
228
-
229
-
const emojiStats = Array.from(emojiCounts.entries())
230
-
.map(([emoji, count]): EmojiStat => ({ emoji, count }))
231
-
.sort((a, b) => b.count - a.count);
232
-
233
-
setEmojiStats(emojiStats);
234
}
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
235
236
// Calculate statistics and chart data
237
if (userEntries.length > 0) {
···
4
import Link from 'next/link';
5
import { useParams } from 'next/navigation';
6
import styles from './profile.module.css';
7
+
import { sanitizeText, containsBannedWords } from '@/lib/content-filter';
8
import { formatRelativeTime } from '@/lib/time-utils';
9
+
10
+
// Define approved emojis list - keep in sync with API route
11
+
const APPROVED_EMOJIS = [
12
+
'🚽', '🧻', '💩', '💨', '🚾', '🧼', '🪠', '🚻', '🩸', '💧', '💦', '😌',
13
+
'😣', '🤢', '🤮', '🥴', '😮💨', '😳', '😵', '🌾', '🍦', '📱', '📖', '💭',
14
+
'1️⃣', '2️⃣', '🟡', '🟤'
15
+
];
16
17
// Types for feed entries
18
interface FlushingEntry {
···
151
});
152
153
if (!recordsResponse.ok) {
154
+
throw new Error(`Failed to fetch records: ${recordsResponse.statusText}`);
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
155
}
156
+
157
+
const recordsData = await recordsResponse.json();
158
+
console.log('Records data:', recordsData);
159
+
160
+
// Transform the records into our format
161
+
const userEntries = recordsData.records
162
+
.map((record: any) => {
163
+
const text = record.value.text || '';
164
+
if (containsBannedWords(text)) return null;
165
+
166
+
return {
167
+
id: record.uri,
168
+
uri: record.uri,
169
+
cid: record.cid,
170
+
did: did,
171
+
text: sanitizeText(text),
172
+
emoji: record.value.emoji || '🚽',
173
+
created_at: record.value.createdAt
174
+
};
175
+
})
176
+
.filter((entry: FlushingEntry | null): entry is FlushingEntry => entry !== null);
177
+
178
+
// Calculate emoji statistics
179
+
const emojiCounts = new Map<string, number>();
180
+
userEntries.forEach((entry: FlushingEntry) => {
181
+
const emoji = entry.emoji?.trim() || '🚽';
182
+
if (APPROVED_EMOJIS.includes(emoji)) {
183
+
emojiCounts.set(emoji, (emojiCounts.get(emoji) || 0) + 1);
184
+
} else {
185
+
emojiCounts.set('🚽', (emojiCounts.get('🚽') || 0) + 1);
186
+
}
187
+
});
188
+
189
+
const emojiStats = Array.from(emojiCounts.entries())
190
+
.map(([emoji, count]): EmojiStat => ({ emoji, count }))
191
+
.sort((a, b) => b.count - a.count);
192
+
193
+
setEntries(userEntries);
194
+
setTotalCount(userEntries.length);
195
+
setEmojiStats(emojiStats);
196
197
// Calculate statistics and chart data
198
if (userEntries.length > 0) {