Skip to content

Commit

Permalink
Merge pull request #1046 from nextcloud-libraries/feat/view-on-toggle…
Browse files Browse the repository at this point in the history
…-open

feat: Allow registration of load child views callback on view
  • Loading branch information
Pytal authored Aug 8, 2024
2 parents df4df29 + b737a98 commit b3561df
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/navigation/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ interface ViewData {
* haven't customized their sorting column
*/
defaultSortKey?: string

/**
* Method called to load child views if any
*/
// eslint-disable-next-line no-use-before-define
loadChildViews?: (view: View) => Promise<void>
}

export class View implements ViewData {
Expand Down Expand Up @@ -157,6 +163,10 @@ export class View implements ViewData {
return this._view.defaultSortKey
}

get loadChildViews() {
return this._view.loadChildViews
}

}

/**
Expand Down Expand Up @@ -222,5 +232,9 @@ const isValidView = function(view: ViewData): boolean {
throw new Error('View defaultSortKey must be a string')
}

if (view.loadChildViews && typeof view.loadChildViews !== 'function') {
throw new Error('View loadChildViews must be a function')
}

return true
}

0 comments on commit b3561df

Please sign in to comment.