|
26 | 26 | import Request from './(components)/Request.svelte';
|
27 | 27 | import Response from './(components)/Response.svelte';
|
28 | 28 | import RateLimits from './(components)/RateLimits.svelte';
|
| 29 | + import type { SDKMethod } from '$lib/utils/specs'; |
29 | 30 |
|
30 | 31 | let { data } = $props();
|
31 | 32 |
|
|
34 | 35 | const headings = getContext<LayoutContext>('headings');
|
35 | 36 |
|
36 | 37 | let selected: string | undefined = $state(undefined);
|
37 |
| - let selectedMenuItem: HTMLElement; |
38 | 38 |
|
39 | 39 | headings.subscribe((n) => {
|
40 | 40 | const noVisible = Object.values(n).every((n) => !n.visible);
|
|
61 | 61 | correctPlatform = platform.replaceAll(`server-`, ``) as Platform;
|
62 | 62 | }
|
63 | 63 |
|
64 |
| - preferredPlatform.set(correctPlatform as Platform); |
| 64 | + if ($preferredPlatform === correctPlatform) return; |
| 65 | +
|
| 66 | + preferredPlatform.set(correctPlatform); |
65 | 67 |
|
66 | 68 | goto(`/docs/references/${version}/${platform}/${service}`, {
|
67 | 69 | noScroll: true
|
|
71 | 73 | function selectVersion(event: CustomEvent<unknown>) {
|
72 | 74 | const { platform, service } = page.params;
|
73 | 75 | const version = event.detail as Version;
|
| 76 | + if ($preferredVersion === version) return; |
| 77 | +
|
74 | 78 | preferredVersion.set(version);
|
75 | 79 | goto(`/docs/references/${version}/${platform}/${service}`, {
|
76 | 80 | noScroll: true
|
|
110 | 114 | : `server-${$preferredPlatform}`;
|
111 | 115 |
|
112 | 116 | goto(`/docs/references/${$preferredVersion}/${platformMode}/${page.params.service}`, {
|
113 |
| - noScroll: true, |
114 |
| - replaceState: false |
| 117 | + noScroll: true |
115 | 118 | });
|
116 | 119 | }
|
117 | 120 |
|
|
145 | 148 | /**
|
146 | 149 | * Sorts methods by their operation order and title
|
147 | 150 | */
|
148 |
| - function sortMethods(methods: any[]) { |
| 151 | + function sortMethods(methods: SDKMethod[]) { |
149 | 152 | return methods.sort((a, b) => {
|
150 | 153 | const orderA = getOperationOrder(a.title);
|
151 | 154 | const orderB = getOperationOrder(b.title);
|
|
156 | 159 | });
|
157 | 160 | }
|
158 | 161 |
|
159 |
| - /** |
160 |
| - * Groups methods by their group attribute, null group goes to '' for ordering |
161 |
| - */ |
162 |
| - function groupMethodsByGroup(methods: any[]) { |
163 |
| - return methods.reduce((acc, method) => { |
| 162 | + function groupMethodsByGroup(methods: SDKMethod[]) { |
| 163 | + return methods.reduce<Record<string, SDKMethod[]>>((acc, method) => { |
164 | 164 | const groupKey = method.group || '';
|
165 | 165 | if (!acc[groupKey]) {
|
166 | 166 | acc[groupKey] = [];
|
|
170 | 170 | }, {});
|
171 | 171 | }
|
172 | 172 |
|
173 |
| - function bindSelectedRef(node: HTMLElement, isSelected: boolean) { |
174 |
| - if (isSelected) { |
175 |
| - selectedMenuItem = node; |
176 |
| - } |
177 |
| -
|
178 |
| - return { |
179 |
| - update(newIsSelected: boolean) { |
180 |
| - if (newIsSelected) { |
181 |
| - selectedMenuItem = node; |
182 |
| - } |
183 |
| - } |
184 |
| - }; |
185 |
| - } |
186 |
| -
|
187 | 173 | let platformBindingForSelect = $derived(page.params.platform as Platform);
|
188 | 174 | let platform = $derived(/**$preferredPlatform ?? */ page.params.platform as Platform);
|
189 | 175 | let platformType = $derived(platform.startsWith('client-') ? 'CLIENT' : 'SERVER');
|
|
400 | 386 | href={`#${method.id}`}
|
401 | 387 | class="web-references-menu-link text-caption"
|
402 | 388 | class:is-selected={method.id === selected}
|
403 |
| - use:bindSelectedRef={method.id === selected} |
404 | 389 | >
|
405 | 390 | {method.title}
|
406 | 391 | </a>
|
|
0 commit comments