Skip to content

Commit

Permalink
refactoring(138): change default options
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed Oct 4, 2023
1 parent 8dac56e commit b0e1321
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface EdgeTopicsOptions {
branchOnly?: boolean
}

const defaultOptions: EdgeTopicsOptions = { publishOnly: true, branchOnly: false }

export const reduceTopicsBy = (options: EdgeTopicsOptions) => (prev: string[], cur: string) => {
if (options.publishOnly && cur.match(/[+#$]/gi)) return prev
if (options.branchOnly) {
Expand Down Expand Up @@ -56,7 +58,7 @@ export const useGetEdgeTopics = (options?: EdgeTopicsOptions): EdgeTopics => {
} = useListBridges()

const data = useMemo<string[]>(() => {
const _options = { publishOnly: true, ...options }
const _options = { ...defaultOptions, ...options }

// return mergeAllTopics(adapters, bridges).filter(filterTopicsBy(_options)).sort()
return mergeAllTopics(adapterTypes, adapters, bridges).reduce<string[]>(reduceTopicsBy(_options), []).sort()
Expand Down

0 comments on commit b0e1321

Please sign in to comment.