From eeed27ffcfc43c2e3eb0e94cb62fb2ea9ea896c7 Mon Sep 17 00:00:00 2001
From: ThaUnknown <6506529+ThaUnknown@users.noreply.github.com>
Date: Sun, 18 Aug 2024 10:22:15 +0200
Subject: [PATCH] feat: better debug tooling, debug mode fix: make account
related buttons disabled when not signed in fix: improve DTS exclusions fix:
softlock on navigation in androidTV
---
capacitor/package.json | 1 +
capacitor/src/capacitor.js | 11 ++
common/components/Menubar.svelte | 16 ++
common/components/Navbar.svelte | 153 ++----------------
common/components/NavbarLink.svelte | 101 ++++++++++++
common/components/Sidebar.svelte | 147 ++++-------------
common/components/SidebarLink.svelte | 129 +++++++++++++++
common/components/banner/FullBanner.svelte | 5 +-
common/components/cards/PreviewCard.svelte | 5 +-
common/modules/click.js | 2 +-
common/modules/rss.js | 2 +-
common/modules/webtorrent.js | 5 +
common/package.json | 1 +
common/views/Settings/AppSettings.svelte | 110 +++++++++++--
.../Settings/HomeSectionsSettings.svelte | 24 +--
common/views/Settings/Settings.svelte | 2 +-
common/views/ViewAnime/ViewAnime.svelte | 9 +-
electron/package.json | 2 +-
electron/src/main/app.js | 5 +-
electron/src/main/debugger.js | 29 ++++
electron/src/main/updater.js | 4 -
pnpm-lock.yaml | 31 +++-
web/src/lib/components/PreviewCard.svelte | 5 +-
23 files changed, 488 insertions(+), 311 deletions(-)
create mode 100644 common/components/NavbarLink.svelte
create mode 100644 common/components/SidebarLink.svelte
create mode 100644 electron/src/main/debugger.js
diff --git a/capacitor/package.json b/capacitor/package.json
index 6dc6e1f..0b2860b 100644
--- a/capacitor/package.json
+++ b/capacitor/package.json
@@ -30,6 +30,7 @@
"@capacitor/app": "^6.0.0",
"@capacitor/browser": "^6.0.1",
"@capacitor/core": "^6.1.1",
+ "@capacitor/device": "^6.0.1",
"@capacitor/ios": "^6.1.1",
"@capacitor/local-notifications": "^6.0.0",
"@capacitor/status-bar": "^6.0.0",
diff --git a/capacitor/src/capacitor.js b/capacitor/src/capacitor.js
index 17d7cae..d190e3b 100644
--- a/capacitor/src/capacitor.js
+++ b/capacitor/src/capacitor.js
@@ -4,6 +4,7 @@ import { SafeArea } from 'capacitor-plugin-safe-area'
import { App } from '@capacitor/app'
import { Browser } from '@capacitor/browser'
import { LocalNotifications } from '@capacitor/local-notifications'
+import { Device } from '@capacitor/device'
import IPC from './ipc.js'
IPC.on('open', url => Browser.open({ url }))
@@ -40,6 +41,16 @@ IPC.on('notification', noti => {
if (canShowNotifications) LocalNotifications.schedule({ notifications: [notification] })
})
+IPC.on('get-device-info', async () => {
+ const deviceInfo = {
+ features: {},
+ info: await Device.getInfo(),
+ cpu: {},
+ ram: {}
+ }
+ IPC.emit('device-info', JSON.stringify(deviceInfo))
+})
+
// schema: miru://key/value
const protocolMap = {
auth: token => sendToken(token),
diff --git a/common/components/Menubar.svelte b/common/components/Menubar.svelte
index ba8ff30..d327cb9 100644
--- a/common/components/Menubar.svelte
+++ b/common/components/Menubar.svelte
@@ -1,4 +1,5 @@
@@ -27,8 +30,21 @@
{/if}
+{#if $debug}
+ Debug Mode!
+{/if}
diff --git a/common/components/NavbarLink.svelte b/common/components/NavbarLink.svelte
new file mode 100644
index 0000000..f12ee41
--- /dev/null
+++ b/common/components/NavbarLink.svelte
@@ -0,0 +1,101 @@
+
+
+
+ {#if image}
+
+
+
+ {:else}
+
{icon}
+ {/if}
+
+
+
diff --git a/common/components/Sidebar.svelte b/common/components/Sidebar.svelte
index 45da2d1..2ea1241 100644
--- a/common/components/Sidebar.svelte
+++ b/common/components/Sidebar.svelte
@@ -5,143 +5,56 @@
import { platformMap } from '@/views/Settings/Settings.svelte'
import { settings } from '@/modules/settings.js'
import { toast } from 'svelte-sonner'
- import { click } from '@/modules/click.js'
import { logout } from './Logout.svelte'
import IPC from '@/modules/ipc.js'
+ import SidebarLink from './SidebarLink.svelte'
- let wasUpdated = false
-
- globalThis.dd = IPC
+ let updateState = ''
IPC.on('update-available', () => {
- console.log('uwu')
- if (!wasUpdated) {
- // insert icon in 2nd to last position
- links.splice(links.length - 1, 0, {
- click: () => {
- toast('Update is downloading...')
- },
- icon: 'download',
- text: 'Update Downloading...'
- })
- links = links
- }
- wasUpdated = true
+ updateState = 'downloading'
})
IPC.on('update-downloaded', () => {
- links[links.length - 2].css = 'update'
- links[links.length - 2].text = 'Update Ready!'
- links[links.length - 2].click = () => {
- IPC.emit('quit-and-install')
- }
- links = links
+ updateState = 'ready'
})
const view = getContext('view')
export let page
- let links = [
- {
- click: () => {
- if (anilistClient.userID?.viewer?.data?.Viewer) {
- $logout = true
- } else {
- IPC.emit('open', 'https://anilist.co/api/v2/oauth/authorize?client_id=4254&response_type=token') // Change redirect_url to miru://auth
- if (platformMap[window.version.platform] === 'Linux') {
- toast('Support Notification', {
- description: "If your linux distribution doesn't support custom protocol handlers, you can simply paste the full URL into the app.",
- duration: 300000
- })
- }
- }
- },
- icon: 'login',
- text: 'Login With AniList',
- css: 'mt-auto'
- },
- {
- click: () => {
- page = 'home'
- },
- page: 'home',
- icon: 'home',
- text: 'Home'
- },
- {
- click: () => {
- page = 'search'
- },
- page: 'search',
- icon: 'search',
- text: 'Search'
- },
- {
- click: () => {
- page = 'schedule'
- },
- page: 'schedule',
- icon: 'schedule',
- text: 'Schedule'
- },
- {
- click: () => {
- if ($media) $view = $media.media
- },
- icon: 'queue_music',
- text: 'Now Playing'
- },
- {
- click: () => {
- page = 'watchtogether'
- },
- page: 'watchtogether',
- icon: 'groups',
- text: 'Watch Together'
- },
- {
- click: () => {
- IPC.emit('open', 'https://github.com/sponsors/ThaUnknown/')
- },
- icon: 'favorite',
- text: 'Support This App',
- css: 'mt-auto donate'
- },
- {
- click: () => {
- page = 'settings'
- },
- page: 'settings',
- icon: 'settings',
- text: 'Settings'
+ function handleAlLogin () {
+ if (anilistClient.userID?.viewer?.data?.Viewer) {
+ $logout = true
+ } else {
+ IPC.emit('open', 'https://anilist.co/api/v2/oauth/authorize?client_id=4254&response_type=token') // Change redirect_url to miru://auth
+ if (platformMap[window.version.platform] === 'Linux') {
+ toast('Support Notification', {
+ description: "If your linux distribution doesn't support custom protocol handlers, you can simply paste the full URL into the app.",
+ duration: 300000
+ })
+ }
}
- ]
- if (anilistClient.userID?.viewer?.data?.Viewer) {
- links[0].image = anilistClient.userID.viewer.data.Viewer.avatar.medium
- links[0].text = 'Logout'
}
diff --git a/common/components/SidebarLink.svelte b/common/components/SidebarLink.svelte
new file mode 100644
index 0000000..80f9352
--- /dev/null
+++ b/common/components/SidebarLink.svelte
@@ -0,0 +1,129 @@
+
+
+
+
+
diff --git a/common/components/banner/FullBanner.svelte b/common/components/banner/FullBanner.svelte
index 76a2aa3..abba439 100644
--- a/common/components/banner/FullBanner.svelte
+++ b/common/components/banner/FullBanner.svelte
@@ -2,6 +2,7 @@
import { formatMap, setStatus, playMedia } from '@/modules/anime.js'
import { anilistClient } from '@/modules/anilist.js'
import { click } from '@/modules/click.js'
+ import { alToken } from '@/modules/settings.js'
export let mediaList
let current = mediaList[0]
@@ -92,10 +93,10 @@
use:click={() => playMedia(current)}>
Watch Now
-