mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
top 8 feature
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
import type { Account } from '../api/types'
|
||||
import { renderHtml, toPlainText } from './html'
|
||||
import { topEightFromHtml } from './top-eight'
|
||||
|
||||
/** The interest rows a MySpace profile shipped with, in their original order. */
|
||||
export const INTEREST_ROWS = ['General', 'Music', 'Movies', 'Television', 'Books', 'Heroes'] as const
|
||||
@@ -70,6 +71,8 @@ export interface ProfileView {
|
||||
about: string
|
||||
/** "Who I'd like to meet" blurb, sanitized HTML. Empty when the user wrote none. */
|
||||
wantsToMeet: string
|
||||
/** Fully-qualified handles declared in the portable bio section. */
|
||||
topEightHandles: string[]
|
||||
interests: InterestEntry[]
|
||||
details: ProfileField[]
|
||||
}
|
||||
@@ -124,7 +127,9 @@ export function fallbackMood(seed: string): string {
|
||||
}
|
||||
|
||||
export function buildProfileView(account: Account): ProfileView {
|
||||
const noteHtml = renderHtml(account.note, { emojis: account.emojis })
|
||||
const renderedNote = renderHtml(account.note, { emojis: account.emojis })
|
||||
const topEight = topEightFromHtml(renderedNote)
|
||||
const noteHtml = topEight.html
|
||||
const { about, meet } = splitBio(noteHtml)
|
||||
|
||||
const interests: InterestEntry[] = []
|
||||
@@ -155,7 +160,7 @@ export function buildProfileView(account: Account): ProfileView {
|
||||
interests.sort((a, b) => INTEREST_ROWS.indexOf(a.row) - INTEREST_ROWS.indexOf(b.row))
|
||||
|
||||
const headlineField = findField(account, ['headline', 'status'])
|
||||
const headline = headlineField ?? firstSentence(toPlainText(account.note)) ?? '"..."'
|
||||
const headline = headlineField ?? firstSentence(toPlainText(noteHtml)) ?? '"..."'
|
||||
|
||||
const ageField = findField(account, ['age'])
|
||||
const parsedAge = ageField ? Number.parseInt(ageField, 10) : Number.NaN
|
||||
@@ -169,6 +174,7 @@ export function buildProfileView(account: Account): ProfileView {
|
||||
age: Number.isFinite(parsedAge) ? parsedAge : null,
|
||||
about,
|
||||
wantsToMeet: meet,
|
||||
topEightHandles: topEight.handles,
|
||||
interests,
|
||||
details,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user