Fix a bug where searching in web app using iOS causes page to reload (#645)
* Fix a bug where searching in web app using iOS causes page to reload * Add cors handler in prod
This commit is contained in:
1 parent
06326d084e
commit
58e2b48409
4 files changed
+84
-67
No files matched your search
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- A bug where it says "(Failed to load)" when switching profiles
|
- A bug where it says "(Failed to load)" when switching profiles
|
||||||
|
- A bug where searching in web app using iOS causes page to reload
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ function SetupRoutes(server as object)
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
'CORS is mostly for developing the web app
|
'CORS is mostly for developing the web app
|
||||||
server.UseRouter(new Http.CorsMiddleware())
|
server.UseRouter(new Http.CorsMiddleware())
|
||||||
|
#else
|
||||||
|
server.UseRouter(new Http.CorsMiddleware(""))
|
||||||
#end if
|
#end if
|
||||||
if server.settings.WebSocketsEnabled
|
if server.settings.WebSocketsEnabled
|
||||||
server.UseRouter(new Http.WebSocketMiddleware())
|
server.UseRouter(new Http.WebSocketMiddleware())
|
||||||
|
|||||||
@@ -20,9 +20,17 @@ namespace Http
|
|||||||
request = context.request
|
request = context.request
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
response.headers["Access-Control-Allow-Origin"] = m.origin
|
if not StringUtils.IsNullOrEmpty(m.origin)
|
||||||
response.headers["Access-Control-Allow-Headers"] = m.headers
|
response.headers["Access-Control-Allow-Origin"] = m.origin
|
||||||
response.headers["Access-Control-Allow-Methods"] = m.methods
|
end if
|
||||||
|
|
||||||
|
if not StringUtils.IsNullOrEmpty(m.headers)
|
||||||
|
response.headers["Access-Control-Allow-Headers"] = m.headers
|
||||||
|
end if
|
||||||
|
|
||||||
|
if not StringUtils.IsNullOrEmpty(m.methods)
|
||||||
|
response.headers["Access-Control-Allow-Methods"] = m.methods
|
||||||
|
end if
|
||||||
|
|
||||||
if request.method = "OPTIONS"
|
if request.method = "OPTIONS"
|
||||||
response.header_only = true
|
response.header_only = true
|
||||||
|
|||||||
@@ -99,6 +99,8 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
// blur to hide the keyboard on mobile
|
||||||
|
searchBox.blur();
|
||||||
const response = await invidiousApi.search(
|
const response = await invidiousApi.search(
|
||||||
searchBoxText,
|
searchBoxText,
|
||||||
searchFilters,
|
searchFilters,
|
||||||
@@ -120,73 +122,76 @@
|
|||||||
|
|
||||||
<div class={visibility ? "" : "hidden"}>
|
<div class={visibility ? "" : "hidden"}>
|
||||||
<div class="m-4">
|
<div class="m-4">
|
||||||
<!-- TODO:P2 use search HTML element -->
|
<search>
|
||||||
<form
|
<form
|
||||||
on:submit={async (e) => {
|
on:submit={async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
page = 1;
|
page = 1;
|
||||||
videos = [];
|
videos = [];
|
||||||
await searchVideos("");
|
await searchVideos("");
|
||||||
}}
|
}}
|
||||||
>
|
|
||||||
<div class="join w-full border border-neutral rounded-full">
|
|
||||||
<input
|
|
||||||
type="search"
|
|
||||||
dir="auto"
|
|
||||||
placeholder="{$translate('Search')}..."
|
|
||||||
class="join-item input w-full border border-neutral rounded-full"
|
|
||||||
bind:this={searchBox}
|
|
||||||
bind:value={searchBoxText}
|
|
||||||
on:input={searchSuggestions}
|
|
||||||
on:focus={searchSuggestions}
|
|
||||||
on:blur={() => {
|
|
||||||
// A delay before clearing the suggestions allows the user to click on a suggestion
|
|
||||||
// Clicking the suggestion will trigger the blur event immediately, and the search won't happen
|
|
||||||
setTimeout(() => {
|
|
||||||
suggestions = { suggestions: [] };
|
|
||||||
}, 200);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
class="join-item btn w-16"
|
|
||||||
on:click={async () => {
|
|
||||||
page = 1;
|
|
||||||
videos = [];
|
|
||||||
await searchVideos("");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="h-6">
|
|
||||||
<SearchThinIcon />
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
class="btn border border-neutral rounded-full mt-1"
|
|
||||||
on:click={searchFiltersComponent.show()}
|
|
||||||
>
|
>
|
||||||
<div class="h-6 w-8">
|
<div class="join w-full border border-neutral rounded-full">
|
||||||
<FiltersIcon />
|
<input
|
||||||
|
type="search"
|
||||||
|
dir="auto"
|
||||||
|
placeholder="{$translate('Search')}..."
|
||||||
|
class="join-item input w-full border border-neutral rounded-full"
|
||||||
|
bind:this={searchBox}
|
||||||
|
bind:value={searchBoxText}
|
||||||
|
on:input={searchSuggestions}
|
||||||
|
on:focus={searchSuggestions}
|
||||||
|
on:blur={() => {
|
||||||
|
// A delay before clearing the suggestions allows the user to click on a suggestion
|
||||||
|
// Clicking the suggestion will trigger the blur event immediately, and the search won't happen
|
||||||
|
setTimeout(() => {
|
||||||
|
suggestions = { suggestions: [] };
|
||||||
|
}, 200);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="join-item btn w-16"
|
||||||
|
on:click={async () => {
|
||||||
|
page = 1;
|
||||||
|
videos = [];
|
||||||
|
await searchVideos("");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class="h-6">
|
||||||
|
<SearchThinIcon />
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{searchFiltersLabel}
|
<button
|
||||||
</button>
|
type="button"
|
||||||
|
class="btn border border-neutral rounded-full mt-1"
|
||||||
{#if suggestions.suggestions.length > 0}
|
on:click={searchFiltersComponent.show()}
|
||||||
<ul
|
|
||||||
class="dropdown-content menu z-10 p-2 shadow-xl bg-base-200 rounded-box"
|
|
||||||
>
|
>
|
||||||
{#each suggestions.suggestions as suggestion}
|
<div class="h-6 w-8">
|
||||||
<li class="p-1">
|
<FiltersIcon />
|
||||||
<button
|
</div>
|
||||||
type="button"
|
{searchFiltersLabel}
|
||||||
on:click={async (e) => {
|
</button>
|
||||||
await suggestionClicked(e.currentTarget.innerText);
|
|
||||||
}}>{@html suggestion}</button
|
{#if suggestions.suggestions.length > 0}
|
||||||
>
|
<ul
|
||||||
</li>
|
class="dropdown-content menu z-10 p-2 shadow-xl bg-base-200 rounded-box"
|
||||||
{/each}
|
>
|
||||||
</ul>
|
{#each suggestions.suggestions as suggestion}
|
||||||
{/if}
|
<li class="p-1">
|
||||||
</form>
|
<button
|
||||||
|
type="button"
|
||||||
|
on:click={async (e) => {
|
||||||
|
await suggestionClicked(e.currentTarget.innerText);
|
||||||
|
}}>{@html suggestion}</button
|
||||||
|
>
|
||||||
|
</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
{/if}
|
||||||
|
</form>
|
||||||
|
</search>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -207,6 +212,7 @@
|
|||||||
{#if !isLoading && videos.length > 0 && searchBoxText}
|
{#if !isLoading && videos.length > 0 && searchBoxText}
|
||||||
<div class="flex justify-center items-center">
|
<div class="flex justify-center items-center">
|
||||||
<button
|
<button
|
||||||
|
type="button"
|
||||||
class="btn w-1/2"
|
class="btn w-1/2"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
page++;
|
page++;
|
||||||
|
|||||||
Reference in new issue
Block a user