rename Model to PeersModel
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
8bfea2f8b3
commit
631a78602e
6
model.go
6
model.go
|
@ -9,12 +9,12 @@ type PeersState struct {
|
||||||
Current int
|
Current int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Model struct {
|
type PeersModel struct {
|
||||||
rematch.Reducer
|
rematch.Reducer
|
||||||
State PeersState
|
State PeersState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) Current(state PeersState, peerIndex int) PeersState {
|
func (m *PeersModel) Current(state PeersState, peerIndex int) PeersState {
|
||||||
// NOTE Not sure if I should just ignore invalid values or panic
|
// NOTE Not sure if I should just ignore invalid values or panic
|
||||||
if peerIndex >= 0 && peerIndex < len(state.Peers) {
|
if peerIndex >= 0 && peerIndex < len(state.Peers) {
|
||||||
state.Current = peerIndex
|
state.Current = peerIndex
|
||||||
|
@ -22,7 +22,7 @@ func (m *Model) Current(state PeersState, peerIndex int) PeersState {
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) Update(state PeersState, peers []Peer) PeersState {
|
func (m *PeersModel) Update(state PeersState, peers []Peer) PeersState {
|
||||||
// The argument is a copy so we can modify it and return it
|
// The argument is a copy so we can modify it and return it
|
||||||
state.Peers = peers
|
state.Peers = peers
|
||||||
// if not current peer is set use first one
|
// if not current peer is set use first one
|
||||||
|
|
4
state.go
4
state.go
|
@ -10,7 +10,7 @@ import (
|
||||||
// This might need renaming, since it also contains the Client.
|
// This might need renaming, since it also contains the Client.
|
||||||
// I need the client to make the RPC calls.
|
// I need the client to make the RPC calls.
|
||||||
type State struct {
|
type State struct {
|
||||||
Reducer *Model
|
Reducer *PeersModel
|
||||||
Store *store.Store
|
Store *store.Store
|
||||||
Client *StatusGoClient
|
Client *StatusGoClient
|
||||||
updatePeers *rematch.Action
|
updatePeers *rematch.Action
|
||||||
|
@ -19,7 +19,7 @@ type State struct {
|
||||||
|
|
||||||
func NewState(client *StatusGoClient) *State {
|
func NewState(client *StatusGoClient) *State {
|
||||||
// Generate the reducer from our model.
|
// Generate the reducer from our model.
|
||||||
Reducer := &Model{
|
Reducer := &PeersModel{
|
||||||
State: PeersState{
|
State: PeersState{
|
||||||
Peers: make([]Peer, 0),
|
Peers: make([]Peer, 0),
|
||||||
Current: -1, // Should mean non selected.
|
Current: -1, // Should mean non selected.
|
||||||
|
|
Loading…
Reference in New Issue