Skip to content

Commit 25da74e

Browse files
refactor: update token deletion API to use DELETE / and implement deep cloning for catalog data in the frontend, removing conditional name handling.
1 parent a43ded9 commit 25da74e

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

app/api/endpoints/tokens.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async def create_token(payload: TokenRequest, request: Request) -> TokenResponse
161161
)
162162

163163

164-
@router.post("/delete", status_code=200)
164+
@router.delete("/", status_code=200)
165165
async def delete_token(payload: TokenRequest):
166166
"""Delete a token based on provided credentials."""
167167
username = payload.username.strip() if payload.username else None

static/script.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const defaultCatalogs = [
55
{ id: 'watchly.theme', name: 'Keyword Genre Based Dynamic Recommendations', enabled: true, description: 'Recommendations based on your favorite genres and themes' },
66
];
77

8-
let catalogs = [...defaultCatalogs];
8+
let catalogs = JSON.parse(JSON.stringify(defaultCatalogs));
99

1010
// DOM Elements
1111
const configForm = document.getElementById('configForm');
@@ -425,7 +425,7 @@ function initializeFormSubmission() {
425425
// Prepare catalog configs
426426
const catalogConfigs = catalogs.map(cat => ({
427427
id: cat.id,
428-
name: cat.name !== getDefaultCatalogName(cat.id) ? cat.name : null,
428+
name: cat.name,
429429
enabled: cat.enabled
430430
}));
431431

@@ -471,10 +471,6 @@ function initializeFormSubmission() {
471471
});
472472
}
473473

474-
function getDefaultCatalogName(id) {
475-
const defaultCat = defaultCatalogs.find(c => c.id === id);
476-
return defaultCat ? defaultCat.name : '';
477-
}
478474

479475
// Success Actions
480476
function initializeSuccessActions() {
@@ -519,7 +515,7 @@ function initializeSuccessActions() {
519515
if (resetBtn) {
520516
resetBtn.addEventListener('click', () => {
521517
configForm.reset();
522-
catalogs = [...defaultCatalogs];
518+
catalogs = JSON.parse(JSON.stringify(defaultCatalogs));
523519
renderCatalogList();
524520
configForm.classList.remove('hidden');
525521
configForm.style.display = ''; // Clear inline style if any
@@ -570,8 +566,8 @@ function initializeSuccessActions() {
570566
hideError();
571567

572568
try {
573-
const response = await fetch('/tokens/delete', {
574-
method: 'POST',
569+
const response = await fetch('/tokens/', {
570+
method: 'DELETE',
575571
headers: {
576572
'Content-Type': 'application/json',
577573
},
@@ -590,7 +586,7 @@ function initializeSuccessActions() {
590586
if (stremioLoginBtn.getAttribute('data-action') === 'logout') {
591587
setStremioLoggedOutState();
592588
}
593-
catalogs = [...defaultCatalogs];
589+
catalogs = JSON.parse(JSON.stringify(defaultCatalogs));
594590
renderCatalogList();
595591

596592
} catch (err) {

0 commit comments

Comments
 (0)