diff --git a/app/api/ltData.ts b/app/api/ltData.ts index de6e7b2..70bc165 100644 --- a/app/api/ltData.ts +++ b/app/api/ltData.ts @@ -15,6 +15,7 @@ interface ApiResponse

{ pages: {[key: string]: P}; categorymembers?: P[]; allpages?: P[]; + allusers?: P[]; }; } @@ -24,6 +25,11 @@ interface Page { title: string; } +interface User { + userid: number; + name: string; +} + interface CoordinatePage { pageid: number; ns: number; @@ -211,6 +217,17 @@ export async function getCategoriesForPrefix(prefix: string): Promise i.title.replace(/^Category:/, '' as CommonsTitle)); } +export async function getUsersForPrefix(prefix: string): Promise { + const params = { + list: 'allusers', + aulimit: 30, + aufrom: prefix, + apuprefix: prefix + }; + const data = await $query>(params, {}, undefined, () => false); + return (data.query.allusers || []).map(i => i.name); +} + export async function getFiles({ files, user, diff --git a/app/components/ltFilesSelector.vue b/app/components/ltFilesSelector.vue index b0eef66..767f18a 100644 --- a/app/components/ltFilesSelector.vue +++ b/app/components/ltFilesSelector.vue @@ -36,7 +36,13 @@

- +
@@ -68,6 +74,10 @@ {{ t('Show User files as gallery') }} + + + +
@@ -185,6 +195,7 @@ const user = ref($route.query.user as string); const userLimit = ref(tryParse(parseInt, $route.query.userLimit as string, undefined)); const userStart = ref($route.query.userStart as string); const userEnd = ref($route.query.userEnd as string); +const userSuggestions = ref([]); const titles = ref(''); function tryParse(parser: (string: string) => T, text: string, fallback: T): T { @@ -213,6 +224,20 @@ watchDebounced( {debounce: 500} ); +watchDebounced( + user, + async user => { + isLoading.value = true; + try { + userSuggestions.value = await ltData.getUsersForPrefix(user); + console.log(userSuggestions.value); + } finally { + isLoading.value = false; + } + }, + {debounce: 500} +); + function next(name = 'geolocate') { const files = titleList.value.join('|'); $routes.push({name, query: {files}});