feat: NSFW for mini-app send mode
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
let items = $state([])
|
||||
let query = $state('')
|
||||
let includeNsfw = $state(false)
|
||||
let loading = $state(true)
|
||||
let error = $state(null)
|
||||
let sending = $state(null) // id медиа, которое сейчас отправляется
|
||||
@@ -26,7 +27,7 @@
|
||||
async function load() {
|
||||
loading = true; error = null; previews = {}
|
||||
try {
|
||||
items = await api.getMedia(query)
|
||||
items = await api.getMedia(query, includeNsfw)
|
||||
for (const item of items) {
|
||||
if (PREVIEWABLE.has(item.mediaType)) loadPreview(item.id)
|
||||
}
|
||||
@@ -76,6 +77,11 @@
|
||||
searchTimer = setTimeout(load, 400)
|
||||
}
|
||||
|
||||
function toggleNsfw() {
|
||||
includeNsfw = !includeNsfw
|
||||
load()
|
||||
}
|
||||
|
||||
onMount(load)
|
||||
</script>
|
||||
|
||||
@@ -96,12 +102,20 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<input
|
||||
class="search"
|
||||
placeholder="Поиск: #мем -#кот слово"
|
||||
bind:value={query}
|
||||
oninput={onSearch}
|
||||
/>
|
||||
<div class="search-row">
|
||||
<input
|
||||
class="search"
|
||||
placeholder="Поиск: #мем -#кот слово"
|
||||
bind:value={query}
|
||||
oninput={onSearch}
|
||||
/>
|
||||
<button
|
||||
class="nsfw-btn"
|
||||
class:nsfw-btn--active={includeNsfw}
|
||||
onclick={toggleNsfw}
|
||||
title={includeNsfw ? 'Скрыть 18+' : 'Показать 18+'}
|
||||
>18+</button>
|
||||
</div>
|
||||
|
||||
{#if loading}
|
||||
<div class="hint">Загрузка…</div>
|
||||
@@ -180,13 +194,30 @@
|
||||
}
|
||||
.chat-name :global(svg) { flex-shrink: 0; color: var(--tg-hint, #888); }
|
||||
|
||||
.search-row {
|
||||
display: flex; align-items: center; gap: 6px;
|
||||
margin: 4px 8px 6px;
|
||||
}
|
||||
.search {
|
||||
margin: 4px 8px 6px; width: calc(100% - 16px);
|
||||
flex: 1; min-width: 0;
|
||||
padding: 8px 12px; border-radius: 8px; border: none;
|
||||
background: var(--tg-secondary-bg, #f0f0f0);
|
||||
color: var(--tg-text, #000); font-size: 14px;
|
||||
}
|
||||
|
||||
.nsfw-btn {
|
||||
flex-shrink: 0;
|
||||
padding: 8px 10px; border-radius: 8px; border: none;
|
||||
background: var(--tg-secondary-bg, #f0f0f0);
|
||||
color: var(--tg-hint, #888); font-size: 13px; font-weight: 600;
|
||||
cursor: pointer; transition: background .15s, color .15s;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.nsfw-btn--active {
|
||||
background: var(--tg-button, #2196f3);
|
||||
color: var(--tg-btn-text, #fff);
|
||||
}
|
||||
|
||||
.hint { text-align: center; padding: 32px; color: var(--tg-hint, #888); }
|
||||
.error { color: #e53935; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user