Preferences / Web App (#79)

* Add basic router

* Add a preferences file

* small changes

* Basic settings navigation menu

* Lint fix

* Add bunch of controls

* Lint fix

* StringControl

* Lint fix

* Add description to keyboard

* Settings saving and loading

* Lint fix

* Settings migration stuff

* GET web api

* Lint fix

* PUT and DELETE (I really fucking hate BrightScript)

* plug in sponsorblock settings

* autoplay, quality, and video proxying

* Remove unused stuff

* Lint fix

* Invidious instance stuff

* cache public instances on start

* Start loading home screen after fetching instances

* Move web app out of settings to its own screen

* picture in picture when in settings

* Web app (#80)

* Update instance stuff

* Update dependencies

* Add basic layout

* Info and settings page, missing styling

* Navbar fixes

* Settings page formatting

* Theme stuff

* Feedback link

* Fix username badge

* Fix svelte warnings

* A wip search page

* Add a couple of api functions

* Wip home screen

* user country code

* Expose token and proxy auth calls

* Use auth requests server side

* Some cleanup

* Add svelte vs code extension

* remove old web app

* More layout stuff

* Tweak for string control

* Filter out old search suggestions

* Search history stuff

* img size for lazy loading

* Basic modal to play video

* Lint fix

* Dependencies bump

* Add video duration and LIVE indicator to cell

* Delete legacy stuff

* Add dev menu

* Lint fix

* Video cell layout

* Cell stuff

* prefs visibility

* Modal layout

* Drag and drop functionality

* Clear search history

* Move web calls to main app

* changelog

* changelog

* Mostly comments

* Lint fix

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
Brahim Hadricheandgithub-action linter authored and GitHub committed 2023-06-24 15:33:09 -04:00
1 parent 9a631aab51
commit 8f8c7d38a8
91 files changed
+3979 -1787

No files matched your search

+71 -38
View File
@@ -1,50 +1,83 @@
<script lang="ts">
import playletLogo from "../assets/logo-dark.svg";
import { PlayletApi } from "./PlayletApi";
import { playletStateStore } from "./Stores";
import playletLogoDark from "../assets/logo-dark.svg";
import playletLogoLight from "../assets/logo-light.svg";
import userIcon from "../assets/user.png";
import { PlayletApi } from "./PlayletApi";
import { appThemeStore, playletStateStore } from "./Stores";
import ThemeSelect from "./ThemeToggle.svelte";
let version;
let loggedIn = false;
let auth_url;
let selectedInstance;
let loggedInInstance;
playletStateStore.subscribe((value) => {
version = value?.app?.version ?? "";
loggedIn = value?.invidious?.logged_in;
auth_url = value?.invidious?.auth_url;
selectedInstance = value?.invidious?.selected_instance;
loggedInInstance = value?.invidious?.logged_in_instance;
});
let version;
let loggedIn = false;
let auth_url;
let currentInstance;
let loggedInInstance;
let username;
const login = () => {
if (!auth_url) {
alert("Error with login, please refresh the page.");
return;
}
window.location = auth_url;
};
const logout = async () => {
await PlayletApi.logout();
// TODO: reload state
window.location.reload();
};
playletStateStore.subscribe((value) => {
version = value?.app?.lib_version ?? "";
loggedIn = value?.invidious?.logged_in;
auth_url = value?.invidious?.auth_url;
currentInstance = value?.invidious?.current_instance;
loggedInInstance = value?.invidious?.logged_in_instance;
username = value?.invidious?.logged_in_username;
});
const login = () => {
if (!auth_url) {
alert("Error with login, please refresh the page.");
return;
}
window.location = auth_url;
};
const logout = async () => {
await PlayletApi.logout();
// TODO: reload state
window.location.reload();
};
</script>
<div class="navbar bg-base-100">
<div class="flex-1">
<img src={playletLogo} class="h-12" alt="Playlet Logo" />
<h4 class="label brightness-75">{version}</h4>
</div>
<div class="flex-none">
<div class="navbar bg-base-100 sticky top-0 z-40">
<div class="flex-1">
<img src={$appThemeStore === 'dark' ? playletLogoDark : playletLogoLight} class="h-8" alt="Playlet Logo" />
<h4 class="label brightness-75">{version}</h4>
</div>
<div class="flex-none">
<ThemeSelect />
{#if loggedIn && username}
<div class="badge badge-outline">
<span>{username}</span>
</div>
{/if}
<div class="dropdown dropdown-end">
<div tabindex="-1" class="btn btn-ghost btn-circle avatar">
<div class="w-8 rounded-full">
<img src={userIcon} alt="User" />
</div>
</div>
<ul
tabindex="-1"
class="menu menu-sm dropdown-content mt-3 p-2 shadow bg-base-100 rounded-box"
>
{#if loggedIn}
<div class="tooltip tooltip-left" data-tip={loggedInInstance}>
<button class="btn" on:click={logout}>Logout</button>
<li>
<div
class="tooltip tooltip-left"
data-tip={`Logout from ${loggedInInstance}`}
>
<button on:click={logout}>Logout</button>
</div>
</li>
{:else}
<div class="tooltip tooltip-left" data-tip={selectedInstance}>
<button class="btn" on:click={login}>Login</button>
<li>
<div
class="tooltip tooltip-left"
data-tip={`Login using ${currentInstance}`}
>
<button on:click={login}>Login</button>
</div>
</li>
{/if}
</ul>
</div>
</div>
</div>