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
6 changes: 6 additions & 0 deletions src/modules/activity/domain/entities/activity-item.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export interface ActivityActor {
export interface ActivityTarget {
type: string;
id: string;
/**
* #144: arah pencarian search-miss. `lemma` = kata Sambas dicari,
* `translation` = kata Indonesia dicari. Null untuk kind lain - mobile
* memakai ini agar prefill form usul mengisi field yang benar.
*/
direction?: 'lemma' | 'translation' | null;
}

export interface ActivityItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ interface FeedRow {
actorAvatarUrl: string | null;
actorDeletedAt: Date | null;
missTerm: string | null;
/** #144: arah search-miss untuk di-wirer ke target.direction di feed. */
missDirection: string | null;
voteValue: number | null;
}

Expand Down Expand Up @@ -354,6 +356,8 @@ export class ActivityEventFeedRepositoryImpl {
// search_miss: term body feed; guard kind supaya kolisi id antar
// tabel (ULID) tak pernah match utk kind lain.
missTerm: searchMisses.term,
// #144: arah search-miss (term Indonesia vs kata Sambas).
missDirection: searchMisses.direction,
// fallback arah vote utk event lama tanpa payload (#94).
voteValue: votes.value,
})
Expand Down Expand Up @@ -576,7 +580,11 @@ export class ActivityEventFeedRepositoryImpl {

private targetFor(
kind: ActivityEventKind,
row: { targetId: string | null; targetWordId: string | null },
row: {
targetId: string | null;
targetWordId: string | null;
missDirection: string | null;
},
word: { id: string; lemma: string } | null,
): ActivityItem['target'] {
switch (kind) {
Expand All @@ -600,7 +608,17 @@ export class ActivityEventFeedRepositoryImpl {
case 'discussion_created':
return row.targetId ? { type: 'discussion', id: row.targetId! } : null;
case 'search_miss':
return row.targetId ? { type: 'search_miss', id: row.targetId! } : null;
return row.targetId
? {
type: 'search_miss',
id: row.targetId!,
// #144: arah pencarian untuk prefill form usul di mobile.
direction:
row.missDirection === 'lemma' || row.missDirection === 'translation'
? row.missDirection
: null,
}
: null;
case 'user_joined':
return row.targetId ? { type: 'user', id: row.targetId! } : null;
case 'announcement':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,11 @@ export class ActivityRepositoryImpl implements ActivityRepository {
target: {
type: 'search_miss',
id: row.id,
// #144: arah pencarian untuk prefill form usul di mobile.
direction:
row.direction === 'lemma' || row.direction === 'translation'
? row.direction
: null,
},
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const activityTargetSchema = z
.object({
type: z.string(),
id: z.string(),
/** #144: arah search-miss untuk prefill form usul (null = kind lain). */
direction: z.enum(['lemma', 'translation']).nullable().optional(),
})
.nullable();

Expand Down
Loading