Skip to content

Commit

Permalink
navigation: Unexport menu entry methods
Browse files Browse the repository at this point in the history
- MenuEntry.IsEqual
- MenuEntry.IsSameResource

Closes #11670
  • Loading branch information
jmooring authored and bep committed Nov 16, 2023
1 parent 805cc17 commit 80d2fdb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions navigation/menu.go
Expand Up @@ -124,14 +124,14 @@ func (m *MenuEntry) hopefullyUniqueID() string {
}
}

// IsEqual returns whether the two menu entries represents the same menu entry.
func (m *MenuEntry) IsEqual(inme *MenuEntry) bool {
// isEqual returns whether the two menu entries represents the same menu entry.
func (m *MenuEntry) isEqual(inme *MenuEntry) bool {
return m.hopefullyUniqueID() == inme.hopefullyUniqueID() && m.Parent == inme.Parent
}

// IsSameResource returns whether the two menu entries points to the same
// isSameResource returns whether the two menu entries points to the same
// resource (URL).
func (m *MenuEntry) IsSameResource(inme *MenuEntry) bool {
func (m *MenuEntry) isSameResource(inme *MenuEntry) bool {
if m.isSamePage(inme.Page) {
return m.Page == inme.Page
}
Expand Down
8 changes: 4 additions & 4 deletions navigation/pagemenus.go
Expand Up @@ -138,7 +138,7 @@ func (pm *pageMenus) HasMenuCurrent(menuID string, me *MenuEntry) bool {

if m, ok := menus[menuID]; ok {
for _, child := range me.Children {
if child.IsEqual(m) {
if child.isEqual(m) {
return true
}
if pm.HasMenuCurrent(menuID, child) {
Expand Down Expand Up @@ -168,7 +168,7 @@ func (pm *pageMenus) IsMenuCurrent(menuID string, inme *MenuEntry) bool {
menus := pm.pagem.Menus()

if me, ok := menus[menuID]; ok {
if me.IsEqual(inme) {
if me.isEqual(inme) {
return true
}
}
Expand All @@ -185,7 +185,7 @@ func (pm *pageMenus) IsMenuCurrent(menuID string, inme *MenuEntry) bool {
// Search for it to make sure that it is in the menu with the given menuId.
if menu, ok := pm.sitem.Menus()[menuID]; ok {
for _, menuEntry := range menu {
if menuEntry.IsSameResource(inme) {
if menuEntry.isSameResource(inme) {
return true
}

Expand All @@ -203,7 +203,7 @@ func (pm *pageMenus) IsMenuCurrent(menuID string, inme *MenuEntry) bool {
func (pm *pageMenus) isSameAsDescendantMenu(inme *MenuEntry, parent *MenuEntry) bool {
if parent.HasChildren() {
for _, child := range parent.Children {
if child.IsSameResource(inme) {
if child.isSameResource(inme) {
return true
}
descendantFound := pm.isSameAsDescendantMenu(inme, child)
Expand Down

0 comments on commit 80d2fdb

Please sign in to comment.