@@ -62,65 +62,67 @@ internal class NavigationManagerWeb : NavigationManager {
62
62
}
63
63
64
64
override fun update (screen : Navigation .Screen ) {
65
- _canPop .value = when (screen) {
66
- Navigation .Screen .About -> true
67
- Navigation .Screen .Libraries -> true
68
- Navigation .Screen .Matcher -> false
69
- Navigation .Screen .Validator -> false
70
- }
71
-
72
65
_current .value = screen
73
66
}
74
67
75
68
override suspend fun emit (event : Navigation .Event ) {
76
69
_event .send(event)
77
70
78
- if (event is Navigation .Event .Navigate ) {
79
- registerHistory(event.screen)
80
- }
71
+ registerHistory(event)
81
72
}
82
73
83
- private fun registerHistory (screen : Navigation .Screen ) {
84
- when (screen) {
85
- Navigation .Screen .Matcher -> {
86
- window.history.go(delta = - stack)
87
- stack = 0
88
- }
74
+ private fun registerHistory (event : Navigation .Event ) {
89
75
90
- Navigation .Screen .About -> {
91
- if (screen is Navigation .Screen .Libraries ) {
92
- window.history.back()
93
- return
76
+ if (event is Navigation .Event .Navigate ) {
77
+ when (event.screen) {
78
+ Navigation .Screen .Matcher -> {
79
+ window.history.pushState(
80
+ data = null ,
81
+ title = " " ,
82
+ url = " ?screen=matcher"
83
+ )
84
+ stack++
94
85
}
95
86
96
- window.history.pushState(
97
- data = null ,
98
- title = " " ,
99
- url = " ?screen=about"
100
- )
101
- stack = 1
102
- }
87
+ Navigation .Screen .Validator -> {
88
+ window.history.pushState(
89
+ data = null ,
90
+ title = " " ,
91
+ url = " ?screen=validator"
92
+ )
103
93
104
- Navigation .Screen .Validator -> {
105
- window.history.pushState(
106
- data = null ,
107
- title = " " ,
108
- url = " ?screen=validator"
109
- )
94
+ stack++
95
+ }
110
96
111
- stack = 1
112
- }
97
+ Navigation .Screen .About -> {
98
+ window.history.pushState(
99
+ data = null ,
100
+ title = " " ,
101
+ url = " ?screen=about"
102
+ )
113
103
114
- Navigation .Screen .Libraries -> {
115
- window.history.pushState(
116
- data = null ,
117
- title = " " ,
118
- url = " ?screen=libraries"
119
- )
120
- stack = 2
104
+ stack++
105
+ }
106
+
107
+ Navigation .Screen .Libraries -> {
108
+ window.history.pushState(
109
+ data = null ,
110
+ title = " " ,
111
+ url = " ?screen=libraries"
112
+ )
113
+
114
+ stack++
115
+ }
121
116
}
122
117
118
+ return
123
119
}
120
+
121
+ if (event == Navigation .Event .OnBack ) {
122
+ window.history.go(delta = -- stack)
123
+ }
124
+
125
+ _canPop .value = stack > 0
124
126
}
125
127
126
128
private suspend fun navigate (query : String ) {
0 commit comments