(data = {})
| 5042 | } |
| 5043 | |
| 5044 | function renderProfileForm(data = {}) { |
| 5045 | const profile = data.profile || {}; |
| 5046 | const raw = data.raw || {}; |
| 5047 | const userId = firstText(raw.user_id, profile.user_id, currentUser()) || "user_demo"; |
| 5048 | const userInfo = selectedUserInfo(userId); |
| 5049 | const directions = sortedProfilePairs(profile, raw, "top_directions", "core_directions"); |
| 5050 | const topics = sortedProfilePairs(profile, raw, "top_topics", "topic_weights"); |
| 5051 | |
| 5052 | state.currentProfile = { profile, raw }; |
| 5053 | $("profileUserId").value = userId; |
| 5054 | $("scholarUrl").value = firstText(raw.scholar_url, raw.scholar_profile?.url, raw.source_inputs?.scholar_url); |
| 5055 | $("homepageUrl").value = firstText(raw.homepage_url, raw.homepage_profile?.url, raw.source_inputs?.homepage_url); |
| 5056 | $("pdfPaths").value = firstText(raw.pdf_paths, raw.source_pdfs, raw.source_inputs?.pdf_paths); |
| 5057 | renderProfileInfoGrid(profile, raw, userInfo, { userId, directions, topics }); |
| 5058 | $("resetProfile").checked = false; |
| 5059 | |
| 5060 | const updatedAt = firstText(profile.updated_at, raw.updated_at, userInfo.updated_at); |
| 5061 | const labels = ui().settings.profileFields; |
| 5062 | setProfileSyncStatus(updatedAt ? `${labels.loaded} · ${updatedAt}` : (userInfo.has_profile ? labels.loaded : labels.missing)); |
| 5063 | } |
| 5064 | |
| 5065 | async function loadCurrentProfile() { |
| 5066 | const userId = currentUser(); |
no test coverage detected