@@ -50,9 +50,22 @@ func (m RootModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
5050 m .sSize = msg
5151 }
5252
53+ if do , m , c := m .WizardStateUpdate (msg ); do {
54+ return m , c
55+ }
56+
57+ if m .currentModel != nil {
58+ w , c := m .currentModel .Update (msg )
59+ m .currentModel = w
60+ return m , c
61+ }
62+ return m , nil
63+ }
64+
65+ func (m RootModel ) WizardStateUpdate (msg tea.Msg ) (bool , tea.Model , tea.Cmd ) {
5366 if _ , ok := msg .(welcomeScreenResult ); ok {
5467 m .currentModel = newInterfaceScreen (m .app , m .sSize )
55- return m , m .currentModel .Init ()
68+ return true , m , m .currentModel .Init ()
5669 }
5770
5871 if msg , ok := msg .(interfaceScreenResult ); ok {
@@ -61,28 +74,29 @@ func (m RootModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
6174
6275 portStep := newPortScreen (m .sSize )
6376 m .currentModel = portStep
64- return m , portStep .Init ()
77+ return true , m , portStep .Init ()
6578 }
6679
6780 if msg , ok := msg .(portStepResult ); ok {
6881 m .blueprint .Port = uint16 (msg )
6982
7083 endStep := newEndpointStep (m .sSize )
7184 m .currentModel = endStep
72- return m , endStep .Init ()
85+ return true , m , endStep .Init ()
7386 }
7487
7588 if msg , ok := msg .(endpointStepResult ); ok {
7689 m .blueprint .Endpoint = string (msg )
7790 netStep := newNetScreen (m .sSize )
7891 m .currentModel = netStep
79- return m , netStep .Init ()
92+ return true , m , netStep .Init ()
8093 }
8194
8295 if msg , ok := msg .(netStepResult ); ok {
8396 m .blueprint .Net4 = msg .net4
8497 m .blueprint .Net6 = msg .net6
85- return m .presentNatDialog ()
98+ m , c := m .presentNatDialog ()
99+ return true , m , c
86100 }
87101
88102 if msg , ok := msg .(optScreenResult ); ok {
@@ -99,14 +113,15 @@ func (m RootModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
99113 m .blueprint .Nat6 = false
100114 }
101115
102- return m .presentDNSDialog ()
116+ m , c := m .presentDNSDialog ()
117+ return true , m , c
103118 }
104119
105120 if msg .id == optIdDNS {
106- m .blueprint .DNS = msg .result .id
121+ m .blueprint .DNS = dnsDict [ msg .result .id ]
107122 doneStep := newDoneScreen (m .app , m .sSize , m .blueprint )
108123 m .currentModel = doneStep
109- return m , doneStep .Init ()
124+ return true , m , doneStep .Init ()
110125 }
111126
112127 }
@@ -118,27 +133,22 @@ func (m RootModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
118133 // extra step to check NAT and setup systemd
119134 rootLinux := newLinuxMoreScreen (m .app , m .sSize , m .blueprint )
120135 m .currentModel = rootLinux
121- return m , rootLinux .Init ()
136+ return true , m , rootLinux .Init ()
122137 }
123138
124- return m , func () tea.Msg {
139+ return true , m , func () tea.Msg {
125140 return Done {InterfaceName : m .blueprint .InterfaceName }
126141 }
127142 }
128143
129144 if _ , ok := msg .(linuxMoreDone ); ok {
130145 m .currentModel = nil
131- return m , func () tea.Msg {
146+ return true , m , func () tea.Msg {
132147 return Done {InterfaceName : m .blueprint .InterfaceName }
133148 }
134149 }
135150
136- if m .currentModel != nil {
137- w , c := m .currentModel .Update (msg )
138- m .currentModel = w
139- return m , c
140- }
141- return m , nil
151+ return false , nil , nil
142152}
143153
144154func (m RootModel ) View () string {
@@ -168,10 +178,10 @@ func (m RootModel) presentNatDialog() (tea.Model, tea.Cmd) {
168178
169179func (m RootModel ) presentDNSDialog () (tea.Model , tea.Cmd ) {
170180 opts := []opt {
171- {"1.1.1.1 " , "Use Cloudflare DNS https://1.1.1.1" },
172- {"8.8.8.8 " , "Use Google DNS https://developers.google.com/speed/public-dns" },
173- {"9.9.9.9 " , "Use Quad9 DNS https://www.quad9.net/" },
174- {"208.67.222.222 " , "Use OpenDNS https://use.opendns.com/" },
181+ {"cloudflare " , "Use Cloudflare DNS https://1.1.1.1" },
182+ {"google " , "Use Google DNS https://developers.google.com/speed/public-dns" },
183+ {"quad9 " , "Use Quad9 DNS https://www.quad9.net/" },
184+ {"opendns " , "Use OpenDNS https://use.opendns.com/" },
175185 }
176186
177187 // shuffle options, so no service will get default treatment (on avarage)
0 commit comments