@@ -101,6 +101,7 @@ type Params = {
101101 kind? : string ,
102102 lock? : string ,
103103};
104+ // given query
104105const query_params = reactive <Params >({});
105106
106107watch (user_repo , val => {
@@ -157,30 +158,6 @@ function get_ck_kinds(ck: string | null): string[] | null {
157158 }
158159 return null ;
159160}
160- // switch to another Get
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- // });
184161
185162function switch_got(g : Get ) {
186163 if (lock_filters ()) return ;
@@ -206,25 +183,20 @@ function switch_got(g: Get) {
206183 if (reset_checker ) selected .checker = null ;
207184}
208185
209- // should be called only once in start-up
210186function lock_filters(): boolean {
211- console .log (" [lock_filters] query_params.lock" , query_params .lock );
212- if (query_params .lock === " true" ) {
187+ const init = query_params .lock === " true" ;
188+ // should be called only once in startup
189+ if (init ) {
213190 lockURL .value = true ;
214- const { user, repo, target, pkg, features, checker, kind } = query_params ;
215- if (user ) selected .user = user ;
216- if (repo ) selected .repo = repo ;
191+ const { target, pkg, features, checker, kind } = query_params ;
217192 if (target && target !== ALL_TARGETS ) selected .target = target ;
218193 if (pkg ) selected .pkg = pkg ;
219194 if (features ) selected .features = features ;
220195 if (checker ) selected .checker = checker ;
221196 if (kind ) selected .kind = kind ;
222197 query_params .lock = undefined ;
223- return true ;
224- } else {
225- lockURL .value = false ;
226- return false
227198 }
199+ return init ;
228200}
229201
230202// watch selection changes
@@ -234,11 +206,8 @@ watch(
234206 kind: selected .kind , ck: selected .checker , g: got .value
235207 }),
236208 ({ 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- }
209+ if (old .g !== g ) return switch_got (g );
210+ lockURL .value = false ;
242211
243212 const val = cloneDeep (g );
244213
@@ -333,14 +302,16 @@ function updateFilter(query: Params) {
333302updateFilter (route .query );
334303
335304const router = useRouter ();
336- const router_params = ref <Params | null >({});
305+ // emit query
306+ const router_params = ref <Params | null >(null );
337307watch (router_params , query => router .push ({ path: route .path , query: query || {} }));
338308
339309watch (lockURL , lock => {
340310 if (! lock ) {
341311 router_params .value = {};
342312 return ;
343313 }
314+
344315 const { user, repo, target, pkg, features, checker, kind } = selected ;
345316
346317 let query: any = {};
0 commit comments