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
|
||||
}
|
||||
|
||||
type Model struct {
|
||||
type PeersModel struct {
|
||||
rematch.Reducer
|
||||
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
|
||||
if peerIndex >= 0 && peerIndex < len(state.Peers) {
|
||||
state.Current = peerIndex
|
||||
|
@ -22,7 +22,7 @@ func (m *Model) Current(state PeersState, peerIndex int) PeersState {
|
|||
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
|
||||
state.Peers = peers
|
||||
// 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.
|
||||
// I need the client to make the RPC calls.
|
||||
type State struct {
|
||||
Reducer *Model
|
||||
Reducer *PeersModel
|
||||
Store *store.Store
|
||||
Client *StatusGoClient
|
||||
updatePeers *rematch.Action
|
||||
|
@ -19,7 +19,7 @@ type State struct {
|
|||
|
||||
func NewState(client *StatusGoClient) *State {
|
||||
// Generate the reducer from our model.
|
||||
Reducer := &Model{
|
||||
Reducer := &PeersModel{
|
||||
State: PeersState{
|
||||
Peers: make([]Peer, 0),
|
||||
Current: -1, // Should mean non selected.
|
||||
|
|
Loading…
Reference in New Issue