Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/src/services/community.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export async function getCommunityJourney(
const userResult = await session.run(
`
MATCH (u:User {username: $username})
RETURN u.username AS username, u.avatarUrl AS avatarUrl, coalesce(u.reputationScore, 0) AS reputationScore
RETURN u.username AS username, u.displayName AS displayName, u.avatarUrl AS avatarUrl, coalesce(u.reputationScore, 0) AS reputationScore
`,
{ username }
);
Expand Down Expand Up @@ -312,6 +312,7 @@ export async function getCommunityJourney(
reputationScore: Number(userRecord!.get("reputationScore"))
},
username: userRecord!.get("username"),
displayName: userRecord!.get("displayName") ?? null,
imageUrl: userRecord!.get("avatarUrl"),
statistics: {
goals: goals.length,
Expand Down
1 change: 1 addition & 0 deletions frontend/api/community.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface SearchCommunityUser {
}

export interface CommunityJourney extends UserJourneyResponse {
displayName?: string | null;
imageUrl?: string | null;
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export default function ResultsPage() {
<TouchableOpacity style={{ height: 56, borderRadius: 28, borderWidth: 2, borderColor: UI.teal, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8 }} onPress={() => {
router.push({
pathname: `/u/${user.username}`, params: {
fromQuery: 'true', imageUrl: user.imageUrl ?? '', expandedDetails: JSON.stringify(user.expandedDetails || { goals: [], experiences: [], transitions: [] })
fromQuery: 'true', displayName: user.displayName ?? '', imageUrl: user.imageUrl ?? '', expandedDetails: JSON.stringify(user.expandedDetails || { goals: [], experiences: [], transitions: [] })
}
});
}}>
Expand Down
11 changes: 6 additions & 5 deletions frontend/app/u/[username].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { WebView } from 'react-native-webview';

export default function PublicProfilePage() {
const router = useRouter();
const { username, fromCommunity, fromQuery, imageUrl, expandedDetails, experienceId } = useLocalSearchParams<{
username: string; fromCommunity?: string; fromQuery?: string; imageUrl?: string; expandedDetails?: string; experienceId?: string;
const { username, fromCommunity, fromQuery, displayName, imageUrl, expandedDetails, experienceId } = useLocalSearchParams<{
username: string; displayName?: string; fromCommunity?: string; fromQuery?: string; imageUrl?: string; expandedDetails?: string; experienceId?: string;
}>();
const goBack = () => {
if (fromCommunity === 'true') router.dismissTo('/(tabs)/community');
Expand Down Expand Up @@ -56,6 +56,7 @@ export default function PublicProfilePage() {

setJourney({
username: username,
displayName: displayName?.trim() || null,
imageUrl: imageUrl || null,
statistics: {
goals: parsedDetails.goals?.length || 0,
Expand All @@ -76,7 +77,7 @@ export default function PublicProfilePage() {
} else {
console.warn("⚠️ No 'username' parameter is present.");
}
}, [username, fromQuery, imageUrl, expandedDetails]);
}, [username, fromQuery, displayName, imageUrl, expandedDetails]);

useEffect(() => {
if (Platform.OS === 'web') {
Expand Down Expand Up @@ -239,12 +240,12 @@ export default function PublicProfilePage() {
<Image source={{ uri: journey.imageUrl }} style={{ width: 48, height: 48 }} />
) : (
<Text style={{ fontSize: 24, color: '#FFFFFF', fontWeight: '700' }}>
{(journey.username || 'U')[0].toUpperCase()}
{(journey.displayName?.trim() || journey.username || 'U')[0].toUpperCase()}
</Text>
)}
</View>
<View>
<Text style={{ fontSize: 16, fontWeight: '500', color: L.navy }}>@{journey.username}</Text>
<Text style={{ fontSize: 16, fontWeight: '500', color: L.navy }}>{journey.displayName?.trim() || `@${journey.username}`}</Text>
<Text style={{ fontSize: 12, fontWeight: '500', color: L.teal, marginTop: 4 }}>
{journey.statistics?.goals || 0} Goals • {journey.statistics?.experiences || 0} Experiences
</Text>
Expand Down
9 changes: 9 additions & 0 deletions frontend/tests/journey-graph.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,12 @@ for (const mode of ['public', 'personal']) {
});
}
}

test('graph display name preserves center identity and legacy fallback', () => {
const journey={username:'test1',displayName:' Rohinth ',goals:[],experiences:[],transitions:[]};
const center=JSON.parse(buildJourneyGraphElements(journey))[0].data;
assert.equal(center.id,'user'); assert.equal(center.label,'Rohinth');
for(const name of [undefined,null,' ']) {
assert.equal(JSON.parse(buildJourneyGraphElements({...journey,displayName:name}))[0].data.label,'@test1');
}
});
14 changes: 14 additions & 0 deletions frontend/tests/publicDisplayName.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const page=readFileSync(new URL('../app/u/[username].tsx',import.meta.url),'utf8');
const results=readFileSync(new URL('../app/results.tsx',import.meta.url),'utf8');
test('search journey navigation passes display name without replacing username path',()=>{
assert.ok(results.includes('pathname: `/u/${user.username}`'));
assert.ok(results.includes("displayName: user.displayName ?? ''"));
});
test('public journey uses optional display name but shares stable username URL',()=>{
assert.ok(page.includes('displayName: displayName?.trim() || null'));
assert.ok(page.includes('journey.displayName?.trim() || `@${journey.username}`'));
assert.ok(page.includes('buildPublicJourneyUrl(journey.username)'));
});
4 changes: 2 additions & 2 deletions frontend/utils/journeyGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { L } from '../constants/colors';

/** Retains the node IDs used by both screens' detail sheets. */
export function buildJourneyGraphElements(
journey: UserJourneyResponse | null,
journey: (UserJourneyResponse & { displayName?: string | null }) | null,
{ filterMissingTransitions = false }: { filterMissingTransitions?: boolean } = {},
): string {
if (!journey) return "[]";
const elements: { data: Record<string, string | number> }[] = [];
// User Node
elements.push({ data: { id: 'user', label: '@' + journey.username, color: L.navy, shape: 'ellipse', textColor: '#fff', borderWidth: 0, borderColor: '#000' } });
elements.push({ data: { id: 'user', label: journey.displayName?.trim() || '@' + journey.username, color: L.navy, shape: 'ellipse', textColor: '#fff', borderWidth: 0, borderColor: '#000' } });

// Goals
journey.goals.forEach(g => {
Expand Down
Loading