mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-22 21:13:09 +02:00
special-case full usernames is search #264
this should be enough "merging" of lookup&search: * partial usernames are searched as part of notes from the widget, and as part of known usernames in "search users" * tags are searched as part of notes from the widget and the "search notes" page * full usernames always navigate to the profile page of that user (which will fetch the profile if possible) as an extra nicety, if "search notes" is disabled, the search widget handles hashtags like the lookup function does
This commit is contained in:
parent
870f70a683
commit
2e55c292bf
2 changed files with 21 additions and 0 deletions
|
@ -65,6 +65,11 @@ async function search() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (query.match(/^@[a-z0-9_.-]+@[a-z0-9_.-]+$/i)) {
|
||||
router.push(`/${query}`);
|
||||
return;
|
||||
}
|
||||
|
||||
userPagination.value = {
|
||||
endpoint: 'users/search',
|
||||
limit: 10,
|
||||
|
|
|
@ -23,6 +23,8 @@ import { i18n } from '@/i18n.js';
|
|||
import * as os from '@/os.js';
|
||||
import { useRouter } from '@/router.js';
|
||||
import { GetFormResultType } from '@/scripts/form.js';
|
||||
import { $i } from '@/account.js';
|
||||
import { instance } from '@/instance.js';
|
||||
|
||||
const name = 'search';
|
||||
|
||||
|
@ -60,6 +62,7 @@ let notePagination = ref();
|
|||
let isLocalOnly = ref(false);
|
||||
let order = ref(true);
|
||||
let filetype = ref<null | string>(null);
|
||||
const notesSearchAvailable = (($i == null && instance.policies.canSearchNotes) || ($i != null && $i.policies.canSearchNotes));
|
||||
|
||||
function options(ev) {
|
||||
os.popupMenu([{
|
||||
|
@ -117,6 +120,19 @@ async function search() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (query.match(/^@[a-z0-9_.-]+@[a-z0-9_.-]+$/i)) {
|
||||
router.push(`/${query}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!notesSearchAvailable && query.startsWith('#')) {
|
||||
// can't really search, at least try handling hashtags
|
||||
router.push(`/tags/${encodeURIComponent(query.substring(1))}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: if !notesSearchAvailable pop up an error message
|
||||
|
||||
notePagination.value = {
|
||||
endpoint: 'notes/search',
|
||||
limit: 10,
|
||||
|
|
Loading…
Reference in a new issue