tangled
alpha
login
or
join now
atpota.to
/
flushes.app
16
fork
atom
The 1st decentralized social network for sharing when you're on the toilet. Post a "flush" today! Powered by the AT Protocol.
16
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
4
import Link from 'next/link';
5
5
import { useParams } from 'next/navigation';
6
6
import styles from './profile.module.css';
7
7
-
import { sanitizeText } from '@/lib/content-filter';
7
7
+
import { sanitizeText, containsBannedWords } from '@/lib/content-filter';
8
8
import { formatRelativeTime } from '@/lib/time-utils';
9
9
+
10
10
+
// Define approved emojis list - keep in sync with API route
11
11
+
const APPROVED_EMOJIS = [
12
12
+
'๐ฝ', '๐งป', '๐ฉ', '๐จ', '๐พ', '๐งผ', '๐ช ', '๐ป', '๐ฉธ', '๐ง', '๐ฆ', '๐',
13
13
+
'๐ฃ', '๐คข', '๐คฎ', '๐ฅด', '๐ฎโ๐จ', '๐ณ', '๐ต', '๐พ', '๐ฆ', '๐ฑ', '๐', '๐ญ',
14
14
+
'1๏ธโฃ', '2๏ธโฃ', '๐ก', '๐ค'
15
15
+
];
9
16
10
17
// Types for feed entries
11
18
interface FlushingEntry {
···
144
151
});
145
152
146
153
if (!recordsResponse.ok) {
147
147
-
// If first attempt fails, try alternative URL pattern
148
148
-
const altUrl = `${serviceEndpoint}/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=im.flushing.right.now&limit=100`;
149
149
-
console.log(`First attempt failed, trying alternative URL: ${altUrl}`);
150
150
-
151
151
-
const altResponse = await fetch(altUrl, {
152
152
-
headers: {
153
153
-
'Accept': 'application/json'
154
154
-
}
155
155
-
});
156
156
-
157
157
-
if (!altResponse.ok) {
158
158
-
throw new Error(`Failed to fetch records: ${altResponse.statusText}`);
159
159
-
}
160
160
-
161
161
-
const recordsData = await altResponse.json();
162
162
-
console.log('Successfully fetched records with alternative URL');
163
163
-
164
164
-
// Process the records
165
165
-
const userEntries = recordsData.records
166
166
-
.map((record: any) => {
167
167
-
const text = record.value.text || '';
168
168
-
if (containsBannedWords(text)) return null;
169
169
-
170
170
-
return {
171
171
-
id: record.uri,
172
172
-
uri: record.uri,
173
173
-
cid: record.cid,
174
174
-
did: did,
175
175
-
text: sanitizeText(text),
176
176
-
emoji: record.value.emoji || '๐ฝ',
177
177
-
created_at: record.value.createdAt
178
178
-
};
179
179
-
})
180
180
-
.filter((entry: any): entry is FlushingEntry => entry !== null);
181
181
-
182
182
-
setEntries(userEntries);
183
183
-
setTotalCount(userEntries.length);
184
184
-
185
185
-
// Calculate emoji stats
186
186
-
const emojiCounts = new Map<string, number>();
187
187
-
userEntries.forEach((entry: FlushingEntry) => {
188
188
-
const emoji = entry.emoji?.trim() || '๐ฝ';
189
189
-
emojiCounts.set(emoji, (emojiCounts.get(emoji) || 0) + 1);
190
190
-
});
191
191
-
192
192
-
const emojiStats = Array.from(emojiCounts.entries())
193
193
-
.map(([emoji, count]): EmojiStat => ({ emoji, count }))
194
194
-
.sort((a, b) => b.count - a.count);
195
195
-
196
196
-
setEmojiStats(emojiStats);
197
197
-
} else {
198
198
-
const recordsData = await recordsResponse.json();
199
199
-
console.log('Successfully fetched records');
200
200
-
201
201
-
// Process the records
202
202
-
const userEntries = recordsData.records
203
203
-
.map((record: any) => {
204
204
-
const text = record.value.text || '';
205
205
-
if (containsBannedWords(text)) return null;
206
206
-
207
207
-
return {
208
208
-
id: record.uri,
209
209
-
uri: record.uri,
210
210
-
cid: record.cid,
211
211
-
did: did,
212
212
-
text: sanitizeText(text),
213
213
-
emoji: record.value.emoji || '๐ฝ',
214
214
-
created_at: record.value.createdAt
215
215
-
};
216
216
-
})
217
217
-
.filter((entry: any): entry is FlushingEntry => entry !== null);
218
218
-
219
219
-
setEntries(userEntries);
220
220
-
setTotalCount(userEntries.length);
221
221
-
222
222
-
// Calculate emoji stats
223
223
-
const emojiCounts = new Map<string, number>();
224
224
-
userEntries.forEach((entry: FlushingEntry) => {
225
225
-
const emoji = entry.emoji?.trim() || '๐ฝ';
226
226
-
emojiCounts.set(emoji, (emojiCounts.get(emoji) || 0) + 1);
227
227
-
});
228
228
-
229
229
-
const emojiStats = Array.from(emojiCounts.entries())
230
230
-
.map(([emoji, count]): EmojiStat => ({ emoji, count }))
231
231
-
.sort((a, b) => b.count - a.count);
232
232
-
233
233
-
setEmojiStats(emojiStats);
154
154
+
throw new Error(`Failed to fetch records: ${recordsResponse.statusText}`);
234
155
}
156
156
+
157
157
+
const recordsData = await recordsResponse.json();
158
158
+
console.log('Records data:', recordsData);
159
159
+
160
160
+
// Transform the records into our format
161
161
+
const userEntries = recordsData.records
162
162
+
.map((record: any) => {
163
163
+
const text = record.value.text || '';
164
164
+
if (containsBannedWords(text)) return null;
165
165
+
166
166
+
return {
167
167
+
id: record.uri,
168
168
+
uri: record.uri,
169
169
+
cid: record.cid,
170
170
+
did: did,
171
171
+
text: sanitizeText(text),
172
172
+
emoji: record.value.emoji || '๐ฝ',
173
173
+
created_at: record.value.createdAt
174
174
+
};
175
175
+
})
176
176
+
.filter((entry: FlushingEntry | null): entry is FlushingEntry => entry !== null);
177
177
+
178
178
+
// Calculate emoji statistics
179
179
+
const emojiCounts = new Map<string, number>();
180
180
+
userEntries.forEach((entry: FlushingEntry) => {
181
181
+
const emoji = entry.emoji?.trim() || '๐ฝ';
182
182
+
if (APPROVED_EMOJIS.includes(emoji)) {
183
183
+
emojiCounts.set(emoji, (emojiCounts.get(emoji) || 0) + 1);
184
184
+
} else {
185
185
+
emojiCounts.set('๐ฝ', (emojiCounts.get('๐ฝ') || 0) + 1);
186
186
+
}
187
187
+
});
188
188
+
189
189
+
const emojiStats = Array.from(emojiCounts.entries())
190
190
+
.map(([emoji, count]): EmojiStat => ({ emoji, count }))
191
191
+
.sort((a, b) => b.count - a.count);
192
192
+
193
193
+
setEntries(userEntries);
194
194
+
setTotalCount(userEntries.length);
195
195
+
setEmojiStats(emojiStats);
235
196
236
197
// Calculate statistics and chart data
237
198
if (userEntries.length > 0) {