@@ -85,13 +85,6 @@ const basic = ref<Basic | null>(null);
8585const user_repo = ref <UserRepo >({});
8686githubFetch <UserRepo >({ path: " ui/user_repo.json" })
8787 .then (data => user_repo .value = data );
88- watch (user_repo , val => {
89- if (! selected .user || ! selected .repo ) {
90- const user = Object .keys (user_repo .value ).sort ()[0 ] ?? " " ;
91- selected .user = user ;
92- selected .repo = val [user ][0 ] ?? " " ;
93- }
94- });
9588
9689// Init filters.
9790const users = computed (() => Object .keys (user_repo .value ).sort ());
@@ -110,6 +103,18 @@ type Params = {
110103};
111104const query_params = reactive <Params >({});
112105
106+ watch (user_repo , val => {
107+ const { user, repo } = query_params ;
108+ if (user && repo ) {
109+ selected .user = user ;
110+ selected .repo = repo ;
111+ } else {
112+ const user = Object .keys (val ).sort ()[0 ] ?? " " ;
113+ selected .user = user ;
114+ selected .repo = val [user ][0 ] ?? " " ;
115+ }
116+ });
117+
113118// Update got state.
114119watch (() => ({ user: selected .user , repo: selected .repo , target: selected .target }),
115120 ({ user , repo , target }) => {
@@ -153,7 +158,31 @@ function get_ck_kinds(ck: string | null): string[] | null {
153158 return null ;
154159}
155160// switch to another Get
156- watch (got , g => {
161+ // watch(got, g => {
162+ // if (lock_filters()) return;
163+ //
164+ // // reset pkg and features since it's less likely to see the same selected pkg in another repo
165+ // selected.pkg = null;
166+ // selected.features = null;
167+ //
168+ // // reset kind if the diagnositc is empty
169+ // selected.kind = Dropdown.find_kind(selected.kind, g);
170+ //
171+ // // reset checker if the diagnositc is empty
172+ // const ck_kinds = get_ck_kinds(selected.checker);
173+ // let reset_checker = true;
174+ // if (ck_kinds) {
175+ // for (const kind of ck_kinds) {
176+ // if (Dropdown.find_kind(kind, g)) {
177+ // reset_checker = false;
178+ // break
179+ // }
180+ // }
181+ // }
182+ // if (reset_checker) selected.checker = null;
183+ // });
184+
185+ function switch_got(g : Get ) {
157186 if (lock_filters ()) return ;
158187
159188 // reset pkg and features since it's less likely to see the same selected pkg in another repo
@@ -175,10 +204,11 @@ watch(got, g => {
175204 }
176205 }
177206 if (reset_checker ) selected .checker = null ;
178- });
207+ }
179208
180209// should be called only once in start-up
181210function lock_filters(): boolean {
211+ console .log (" [lock_filters] query_params.lock" , query_params .lock );
182212 if (query_params .lock === " true" ) {
183213 lockURL .value = true ;
184214 const { user, repo, target, pkg, features, checker, kind } = query_params ;
@@ -203,7 +233,12 @@ watch(
203233 pkg: selected .pkg , feat: selected .features ,
204234 kind: selected .kind , ck: selected .checker , g: got .value
205235 }),
206- ({ pkg , feat , kind , ck , g }) => {
236+ ({ pkg , feat , kind , ck , g }, old ) => {
237+ if (old .g !== g ) {
238+ console .log (" switch_got" , old .g , g );
239+ switch_got (g );
240+ return ;
241+ }
207242
208243 const val = cloneDeep (g );
209244
0 commit comments