Multiple profiles (#312)
* Navbar user profile * profiles stuff * fix profile * Lint fix * Some ui experiments * More ui work * progress * Lint fix * migration, web api, wip * profile view and web app * web app and apis * Invidious and profiles * Lint fix * bug fix * Remove ActionContentNode * Profile icon button, profile color * Lint fix * reset server url * href that doesn't work * remove activate button on active profile * TODO * Fin. * Final touches --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
8e03ca0ea6
commit
394dd23999
60 files changed
+1725
-311
No files matched your search
@@ -1,55 +1,48 @@
|
||||
<script lang="ts">
|
||||
import PlayletLogoDark from "assets/logo-dark.svg.svelte";
|
||||
import PlayletLogoLight from "assets/logo-light.svg.svelte";
|
||||
import UserIcon from "assets/user.svg.svelte";
|
||||
import { PlayletApi } from "lib/Api/PlayletApi";
|
||||
import { ExternalControlProtocol } from "lib/Api/ExternalControlProtocol";
|
||||
import { appThemeStore, playletStateStore } from "lib/Stores";
|
||||
import ThemeSelect from "lib/ThemeToggle.svelte";
|
||||
import ProfilesDialog from "./ProfilesDialog.svelte";
|
||||
import ProfileAvatar from "./ProfileAvatar.svelte";
|
||||
|
||||
let profilesDialog;
|
||||
let version;
|
||||
let loggedIn = false;
|
||||
let auth_url;
|
||||
let currentInstance;
|
||||
let loggedInInstance;
|
||||
let username;
|
||||
let currentProfile;
|
||||
let appId = "693751";
|
||||
|
||||
playletStateStore.subscribe((value) => {
|
||||
version = value?.app?.lib_version ?? "";
|
||||
version = getAppVersion(value);
|
||||
if (value?.app?.id) {
|
||||
appId = value?.app?.id;
|
||||
}
|
||||
let profiles = value?.profiles?.profiles ?? [];
|
||||
currentProfile = profiles.find(
|
||||
(p) => p.id === value?.profiles?.currentProfile
|
||||
);
|
||||
});
|
||||
|
||||
const showProfilesDialog = () => {
|
||||
profilesDialog.show();
|
||||
};
|
||||
|
||||
function getAppVersion(playletState) {
|
||||
let version = playletState?.app?.lib_version ?? "";
|
||||
const appId = playletState?.app?.id;
|
||||
if (appId === "dev") {
|
||||
version += "-dev";
|
||||
}
|
||||
|
||||
if (
|
||||
value?.app?.lib_url_type === "custom" &&
|
||||
value?.app?.lib_url ===
|
||||
playletState?.app?.lib_url_type === "custom" &&
|
||||
playletState?.app?.lib_url ===
|
||||
"https://github.com/iBicha/playlet/releases/download/canary/playlet-lib.zip"
|
||||
) {
|
||||
version += "-canary";
|
||||
}
|
||||
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();
|
||||
PlayletApi.getState().then((value) => {
|
||||
playletStateStore.set(value);
|
||||
});
|
||||
};
|
||||
return version;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="navbar bg-base-100 sticky top-0 z-40">
|
||||
@@ -65,41 +58,18 @@
|
||||
</div>
|
||||
<div class="flex-none">
|
||||
<ThemeSelect />
|
||||
{#if loggedIn && username}
|
||||
{#if currentProfile && currentProfile.username}
|
||||
<div class="badge badge-outline">
|
||||
<span>{username}</span>
|
||||
<span>{currentProfile.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">
|
||||
<UserIcon />
|
||||
</div>
|
||||
</div>
|
||||
<ul
|
||||
tabindex="-1"
|
||||
class="menu menu-sm dropdown-content mt-3 p-2 shadow bg-base-100 rounded-box"
|
||||
>
|
||||
{#if loggedIn}
|
||||
<li>
|
||||
<div
|
||||
class="tooltip tooltip-left"
|
||||
data-tip={`Logout from ${loggedInInstance}`}
|
||||
>
|
||||
<button on:click={logout}>Logout</button>
|
||||
</div>
|
||||
</li>
|
||||
{:else}
|
||||
<li>
|
||||
<div
|
||||
class="tooltip tooltip-left"
|
||||
data-tip={`Login using ${currentInstance}`}
|
||||
>
|
||||
<button on:click={login}>Login to Invidious</button>
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
<button
|
||||
on:click={showProfilesDialog}
|
||||
class="btn btn-ghost btn-circle avatar"
|
||||
>
|
||||
<ProfileAvatar />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ProfilesDialog bind:this={profilesDialog} />
|
||||
Reference in new issue
Block a user