Skip to content

Commit 300c040

Browse files
committed
improved opening of profile pane
1 parent 3e8d20e commit 300c040

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/mainPage/menu.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import './menu.css'
22
import { OutlineManager } from '../outline/manager'
3-
import { authSession } from 'solid-logic'
3+
import { authSession, authn } from 'solid-logic'
44
import { NamedNode } from 'rdflib'
5+
import { loadProfileFromURI } from '../profileUtils/ownerProfile'
56

67
type MenuItem = {
78
id?: string
@@ -230,6 +231,18 @@ export const createLeftSideMenu = async (subject: NamedNode, outliner: OutlineMa
230231
}
231232

232233
async function openDashboardPane (subject, outliner: any, pane: string): Promise<void> {
234+
const me = authn.currentUser()
235+
if (me) {
236+
subject = me
237+
} else {
238+
const store = outliner?.context?.store || outliner?.context?.session?.store || outliner?.kb
239+
const fetcher = outliner?.context?.fetcher || store?.fetcher
240+
if (!store || !fetcher) {
241+
throw new Error('Unable to load profile: missing RDF store or fetcher')
242+
}
243+
subject = await loadProfileFromURI(subject, store, fetcher)
244+
}
245+
console.log(`-----Opening dashboard pane ${pane} for`, subject)
233246
outliner.showDashboard(subject, {
234247
pane
235248
})

src/profileUtils/ownerProfile.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,26 @@ export async function loadProfileFromURI (
1717
// TODO: This is a hack - we cannot assume that the profile is at this document, but we will live with it for now
1818
const webId = sym(`${pod}${DEFAULT_PROFILE_PATH}`)
1919
try {
20+
console.log('-----Trying to load prefixed pod profile', webId)
2021
await fetcher.load(webId)
2122
return webId
2223
} catch (err) {
23-
// Fall back to pod root and any discovered profile links.
24+
// continue
25+
}
26+
27+
// we try a prefixed pod structure
28+
try {
29+
const uriUrl = new URL(uri.uri)
30+
const pathSegments = uriUrl.pathname.split('/').filter(Boolean)
31+
if (pathSegments.length > 0) {
32+
const derivedPod = `${uriUrl.origin}/${pathSegments[0]}/`
33+
const derivedWebId = sym(`${derivedPod}${DEFAULT_PROFILE_PATH}`)
34+
console.log('-----Trying to load suffixed pod profile', derivedWebId)
35+
await fetcher.load(derivedWebId)
36+
return derivedWebId
37+
}
38+
} catch (err) {
39+
// continue
2440
}
2541

2642
try {

0 commit comments

Comments
 (0)