Skip to content

Commit 707a5d6

Browse files
committed
show req tab when owner only
1 parent bc143c6 commit 707a5d6

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/social/socialPane.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const socialPane = {
202202
const outliner = context.getOutliner(dom)
203203
const kb = context.session.store
204204
const socialPane = dom.createElement('div')
205-
socialPane.classList.add('social-pane', 'flex-column', 'gap-xxs', 'p-lg')
205+
socialPane.classList.add('social-pane', 'flex-column', 'gap-xxs')
206206
applyEnvironmentAttributes(socialPane, context)
207207
const foaf = ns.foaf
208208
const vcard = ns.vcard
@@ -347,6 +347,10 @@ export const socialPane = {
347347
: undefined
348348
}, function () {
349349
return selectProfileData(context, s)
350+
}, {
351+
onAddFriendSuccess: function () {
352+
refreshRelationshipUi()
353+
}
350354
})
351355
header.classList.add('social-pane__header-section', 'flex-column')
352356
socialPane.prepend(header)
@@ -482,12 +486,13 @@ export const socialPane = {
482486

483487
type SocialPanel = 'mutual' | 'all-friends' | 'requests'
484488
let activePanel: SocialPanel = 'all-friends'
489+
let showRequestsTab = viewerMode === 'owner'
485490

486491
const setActivePanel = function (panel: SocialPanel) {
487492
activePanel = panel
488493
const showMutual = panel === 'mutual'
489494
const showAllFriends = panel === 'all-friends'
490-
const showRequests = panel === 'requests'
495+
const showRequests = showRequestsTab && panel === 'requests'
491496
mutualTab.classList.toggle('social-primary__tab--active', showMutual)
492497
mutualTab.setAttribute('aria-selected', String(showMutual))
493498
mutualTab.tabIndex = showMutual ? 0 : -1
@@ -508,6 +513,7 @@ export const socialPane = {
508513

509514
requestsPanel.classList.toggle('social-primary__panel--active', showRequests)
510515
requestsPanel.setAttribute('aria-hidden', String(!showRequests))
516+
requestsPanel.hidden = !showRequestsTab || !showRequests
511517
}
512518
/* The following function was generated by AI GPT-5.4 Model
513519
Prompt: After friend is added when mutual checkbox is checked refresh
@@ -562,8 +568,13 @@ export const socialPane = {
562568

563569
const applyViewerMode = function (mode: ViewerMode) {
564570
const showMutualTab = mode === 'authenticated' && !thisIsYou
571+
showRequestsTab = mode === 'owner'
565572
mutualTab.hidden = !showMutualTab
566-
requestsTab.hidden = false
573+
requestsTab.hidden = !showRequestsTab
574+
if (!showRequestsTab && activePanel === 'requests') {
575+
setActivePanel('all-friends')
576+
return
577+
}
567578
setActivePanel('all-friends')
568579
}
569580

0 commit comments

Comments
 (0)