Skip to content

Commit 7107789

Browse files
committed
use the extracted function and clean up the props
1 parent 9cf468a commit 7107789

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

source/views/home/home.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,17 @@ import type {TopLevelViewPropsType} from '../types'
1414
import type {ViewType} from '../views'
1515
import {allViews} from '../views'
1616
import {Column} from '../components/layout'
17+
import {partitionByIndex} from '../../lib/partition-by-index'
1718
import {HomeScreenButton, CELL_MARGIN} from './button'
1819
import {trackedOpenUrl} from '../components/open-url'
1920
import {EditHomeButton, OpenSettingsButton} from '../components/nav-buttons'
2021

21-
function partitionByIndex<T>(arr: T[]): [T[], T[]] {
22-
return arr.reduce(
23-
(acc, val, idx) => {
24-
return idx % 2 === 0
25-
? [acc[0].concat(val), acc[1]]
26-
: [acc[0], acc[1].concat(val)]
27-
},
28-
[[], []],
29-
)
22+
type Props = TopLevelViewPropsType & {
23+
order: string[],
24+
views: ViewType[],
3025
}
3126

32-
function HomePage({
33-
navigation,
34-
order,
35-
views = allViews,
36-
}: {order: string[], views: ViewType[]} & TopLevelViewPropsType) {
27+
function HomePage({navigation, order, views = allViews}: Props) {
3728
const sortedViews = sortBy(views, view => order.indexOf(view.view))
3829

3930
const columns = partitionByIndex(sortedViews)

0 commit comments

Comments
 (0)