fix profile card.old icon
This commit is contained in:
@@ -9,14 +9,8 @@ export interface ServiceLink {
|
|||||||
collection: string
|
collection: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migration state for api.syui.ai users
|
|
||||||
export interface MigrationInfo {
|
|
||||||
hasOldApi: boolean
|
|
||||||
hasMigrated: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get available services based on user's collections
|
// Get available services based on user's collections
|
||||||
export function getServiceLinks(handle: string, collections: string[], migration?: MigrationInfo): ServiceLink[] {
|
export function getServiceLinks(handle: string, collections: string[]): ServiceLink[] {
|
||||||
const services: ServiceLink[] = []
|
const services: ServiceLink[] = []
|
||||||
|
|
||||||
if (collections.includes('ai.syui.card.user')) {
|
if (collections.includes('ai.syui.card.user')) {
|
||||||
@@ -28,8 +22,8 @@ export function getServiceLinks(handle: string, collections: string[], migration
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add migration link if user has api.syui.ai account
|
// Card (old) - show if user has ai.syui.card.old collection
|
||||||
if (migration?.hasOldApi) {
|
if (collections.includes('ai.syui.card.old')) {
|
||||||
services.push({
|
services.push({
|
||||||
name: 'Card (old)',
|
name: 'Card (old)',
|
||||||
icon: '/service/ai.syui.card.old.png',
|
icon: '/service/ai.syui.card.old.png',
|
||||||
@@ -57,8 +51,7 @@ export async function renderProfile(
|
|||||||
handle: string,
|
handle: string,
|
||||||
webUrl?: string,
|
webUrl?: string,
|
||||||
localOnly = false,
|
localOnly = false,
|
||||||
collections: string[] = [],
|
collections: string[] = []
|
||||||
migration?: MigrationInfo
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
// Local mode: sync, no API call. Remote mode: async with API call
|
// Local mode: sync, no API call. Remote mode: async with API call
|
||||||
const avatarUrl = localOnly
|
const avatarUrl = localOnly
|
||||||
@@ -78,10 +71,10 @@ export async function renderProfile(
|
|||||||
? `<img src="${avatarUrl}" alt="${escapeHtml(displayName)}" class="profile-avatar">`
|
? `<img src="${avatarUrl}" alt="${escapeHtml(displayName)}" class="profile-avatar">`
|
||||||
: `<div class="profile-avatar-placeholder"></div>`
|
: `<div class="profile-avatar-placeholder"></div>`
|
||||||
|
|
||||||
// Service icons (show for users with matching collections or migration available)
|
// Service icons (show for users with matching collections)
|
||||||
let serviceIconsHtml = ''
|
let serviceIconsHtml = ''
|
||||||
if (collections.length > 0 || migration?.hasOldApi) {
|
if (collections.length > 0) {
|
||||||
const services = getServiceLinks(handle, collections, migration)
|
const services = getServiceLinks(handle, collections)
|
||||||
if (services.length > 0) {
|
if (services.length > 0) {
|
||||||
const iconsHtml = services.map(s => `
|
const iconsHtml = services.map(s => `
|
||||||
<a href="${s.url}" class="service-icon-link" title="${s.name}">
|
<a href="${s.url}" class="service-icon-link" title="${s.name}">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import './styles/main.css'
|
import './styles/main.css'
|
||||||
import './styles/card.css'
|
import './styles/card.css'
|
||||||
import './styles/card-migrate.css'
|
import './styles/card-migrate.css'
|
||||||
import { getConfig, resolveHandle, getProfile, getPosts, getPost, describeRepo, listRecords, getRecord, getPds, getNetworks, getChatMessages, getCards, getRse, getOldApiUserByDid, hasCardOldRecord } from './lib/api'
|
import { getConfig, resolveHandle, getProfile, getPosts, getPost, describeRepo, listRecords, getRecord, getPds, getNetworks, getChatMessages, getCards, getRse } from './lib/api'
|
||||||
import { parseRoute, onRouteChange, navigate, type Route } from './lib/router'
|
import { parseRoute, onRouteChange, navigate, type Route } from './lib/router'
|
||||||
import { login, logout, handleCallback, restoreSession, isLoggedIn, getLoggedInHandle, getLoggedInDid, deleteRecord, updatePost } from './lib/auth'
|
import { login, logout, handleCallback, restoreSession, isLoggedIn, getLoggedInHandle, getLoggedInDid, deleteRecord, updatePost } from './lib/auth'
|
||||||
import { validateRecord } from './lib/lexicon'
|
import { validateRecord } from './lib/lexicon'
|
||||||
@@ -176,16 +176,9 @@ async function render(route: Route): Promise<void> {
|
|||||||
const loggedInDid = getLoggedInDid()
|
const loggedInDid = getLoggedInDid()
|
||||||
const isOwner = isLoggedIn() && loggedInDid === did
|
const isOwner = isLoggedIn() && loggedInDid === did
|
||||||
|
|
||||||
// Check migration status (api.syui.ai -> ATProto)
|
|
||||||
const [oldApiUser, hasMigrated] = await Promise.all([
|
|
||||||
getOldApiUserByDid(did),
|
|
||||||
hasCardOldRecord(did)
|
|
||||||
])
|
|
||||||
const migration = oldApiUser ? { hasOldApi: true, hasMigrated } : undefined
|
|
||||||
|
|
||||||
// Profile section
|
// Profile section
|
||||||
if (profile) {
|
if (profile) {
|
||||||
html += await renderProfile(did, profile, handle, webUrl, localOnly, collections, migration)
|
html += await renderProfile(did, profile, handle, webUrl, localOnly, collections)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Content section based on route type
|
// Content section based on route type
|
||||||
|
|||||||
Reference in New Issue
Block a user