Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Extracted screens into constants #561

Merged
merged 1 commit into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/consts/screen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const INTRO = 'intro'
export const DATS = 'dats'
export const DOWNLOAD = 'download'
export const INSPECT = 'inspect'

export default {
INTRO,
DATS,
DOWNLOAD,
INSPECT
}
3 changes: 2 additions & 1 deletion app/containers/download.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

import SCREEN from '../consts/screen'
import Download from '../components/download'
import {
addDat,
Expand All @@ -10,7 +11,7 @@ import {
import { connect } from 'react-redux'

const mapStateToProps = state => ({
show: state.screen === 'download',
show: state.screen === SCREEN.DOWNLOAD,
dat: state.dats[state.downloadDatKey]
})

Expand Down
3 changes: 2 additions & 1 deletion app/containers/intro.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict'

import SCREEN from '../consts/screen'
import { connect } from 'react-redux'
import IntroScreen from '../components/intro'
import { openHomepage, nextIntro, hideIntro } from '../actions'

const mapStateToProps = state => ({
show: state.screen === 'intro',
show: state.screen === SCREEN.INTRO,
screen: state.intro.screen
})

Expand Down
3 changes: 2 additions & 1 deletion app/containers/status-bar.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict'

import SCREEN from '../consts/screen'
import StatusBar from '../components/status-bar'
import { connect } from 'react-redux'

const mapStateToProps = state => ({
up: state.speed.up,
down: state.speed.down,
show: state.screen === 'dats'
show: state.screen === SCREEN.DATS
})

const mapDispatchToProps = dispatch => ({})
Expand Down
3 changes: 2 additions & 1 deletion app/containers/table.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict'

import SCREEN from '../consts/screen'
import Table from '../components/table'
import { connect } from 'react-redux'

const mapStateToProps = state => ({
dats: state.dats,
show: state.screen === 'dats'
show: state.screen === SCREEN.DATS
})

const TableContainer = connect(mapStateToProps, null)(Table)
Expand Down
18 changes: 10 additions & 8 deletions app/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
'use strict'

import SCREEN from '../consts/screen'

const defaultState = {
dats: {},
screen: 'intro',
screen: SCREEN.INTRO,
dialogs: {
link: {
link: null,
Expand Down Expand Up @@ -42,18 +44,18 @@ const redatApp = (state = defaultState, action) => {
document.title = 'Dat Desktop'
return {
...state,
screen: 'dats'
screen: SCREEN.DATS
}
case 'SHOW_DOWNLOAD_SCREEN':
return {
...state,
screen: 'download',
screen: SCREEN.DOWNLOAD,
downloadDatKey: action.key
}
case 'HIDE_DOWNLOAD_SCREEN':
return {
...state,
screen: 'dats',
screen: SCREEN.DATS,
downloadDatKey: null
}
case 'CHANGE_DOWNLOAD_PATH':
Expand Down Expand Up @@ -86,7 +88,7 @@ const redatApp = (state = defaultState, action) => {
}
}
},
screen: 'dats'
screen: SCREEN.DATS
}
case 'ADD_DAT_ERROR':
case 'WRITE_METADATA_ERROR':
Expand Down Expand Up @@ -118,15 +120,15 @@ const redatApp = (state = defaultState, action) => {
case 'INSPECT_DAT':
return {
...state,
screen: 'inspect',
screen: SCREEN.INSPECT,
inspect: {
key: action.key
}
}
case 'INSPECT_DAT_CLOSE':
return {
...state,
screen: 'dats'
screen: SCREEN.DATS
}
case 'DAT_FILES':
return {
Expand Down Expand Up @@ -286,7 +288,7 @@ const redatApp = (state = defaultState, action) => {
case 'DIALOGS_DELETE_CLOSE':
return {
...state,
screen: 'dats',
screen: SCREEN.DATS,
dialogs: {
...state.dialogs,
delete: {
Expand Down