[perf] reduce number of rendezvous when reading invidious instance name
This commit is contained in:
1 parent
c70d00e156
commit
75e6848df8
8 files changed
+31
-22
No files matched your search
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- A bug preventing the removal of bookmarked private playlists
|
- A bug preventing the removal of bookmarked private playlists
|
||||||
|
- [perf] Reduce number of rendezvous when reading invidious instance name
|
||||||
|
- Also fixes an edge case error when device loses connectivity
|
||||||
|
|
||||||
## [0.40.8] - 2025-06-22
|
## [0.40.8] - 2025-06-22
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace Invidious
|
|||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
return m.GetPlayletBuiltinInstance()
|
return PLAYLET_BUILT_IN_INSTANCE
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetInvidiousInstance() as string
|
function GetInvidiousInstance() as string
|
||||||
@@ -89,15 +89,6 @@ namespace Invidious
|
|||||||
return m.preferences["invidious.instance"]
|
return m.preferences["invidious.instance"]
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetPlayletBuiltinInstance() as string
|
|
||||||
instance = PLAYLET_BUILT_IN_INSTANCE
|
|
||||||
address = m.invidiousNode.webServer@.GetServerAddress()
|
|
||||||
if not StringUtils.IsNullOrEmpty(address)
|
|
||||||
instance = instance.Replace("http://127.0.0.1:8888", address)
|
|
||||||
end if
|
|
||||||
return instance
|
|
||||||
end function
|
|
||||||
|
|
||||||
function MarkVideoWatched(videoId as dynamic, cancellation = invalid as object) as void
|
function MarkVideoWatched(videoId as dynamic, cancellation = invalid as object) as void
|
||||||
if StringUtils.IsNullOrEmpty(videoId)
|
if StringUtils.IsNullOrEmpty(videoId)
|
||||||
return
|
return
|
||||||
@@ -742,7 +733,7 @@ namespace Invidious
|
|||||||
function GetAuthorizeTokenLink() as dynamic
|
function GetAuthorizeTokenLink() as dynamic
|
||||||
instance = m.GetInvidiousInstance()
|
instance = m.GetInvidiousInstance()
|
||||||
if StringUtils.IsNullOrEmpty(instance)
|
if StringUtils.IsNullOrEmpty(instance)
|
||||||
instance = m.GetPlayletBuiltinInstance()
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
' Make sure the host is not on https, because https cannot redirect to http, which is our local server
|
' Make sure the host is not on https, because https cannot redirect to http, which is our local server
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import { PlayletApi } from "lib/Api/PlayletApi";
|
import { PlayletApi } from "lib/Api/PlayletApi";
|
||||||
|
import { getHost } from "./Host";
|
||||||
|
|
||||||
const DISABLE_CACHE = true;
|
const DISABLE_CACHE = true;
|
||||||
|
|
||||||
export class InvidiousApi {
|
export class InvidiousApi {
|
||||||
public instance: string;
|
static host = () => `http://${getHost()}`
|
||||||
|
|
||||||
public endpoints: any;
|
public endpoints: any;
|
||||||
public isLoggedIn: boolean = false;
|
public isLoggedIn: boolean = false;
|
||||||
public userCountryCode: string = 'US';
|
public userCountryCode: string = 'US';
|
||||||
|
private instance: string;
|
||||||
|
|
||||||
responseHandlers: any;
|
responseHandlers: any;
|
||||||
|
|
||||||
@@ -23,6 +26,18 @@ export class InvidiousApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setInstance(instance: string) {
|
||||||
|
if (!instance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (instance.startsWith("http://127.0.0.1:8888")) {
|
||||||
|
instance = instance.replace("http://127.0.0.1:8888", InvidiousApi.host());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.instance = instance;
|
||||||
|
}
|
||||||
|
|
||||||
public async searchSuggestions(query: string) {
|
public async searchSuggestions(query: string) {
|
||||||
const url = `${this.instance}/api/v1/search/suggestions?q=${encodeURIComponent(query)}®ion=${this.userCountryCode}`;
|
const url = `${this.instance}/api/v1/search/suggestions?q=${encodeURIComponent(query)}®ion=${this.userCountryCode}`;
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
let invidiousApi = new InvidiousApi();
|
let invidiousApi = new InvidiousApi();
|
||||||
|
|
||||||
playletStateStore.subscribe((value) => {
|
playletStateStore.subscribe((value) => {
|
||||||
invidiousApi.instance = value?.invidious?.instance;
|
invidiousApi.setInstance(value?.invidious?.instance);
|
||||||
});
|
});
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
import { playletStateStore, translate } from "lib/Stores";
|
import { playletStateStore, translate } from "lib/Stores";
|
||||||
import { PlayletApi } from "./Api/PlayletApi";
|
import { PlayletApi } from "./Api/PlayletApi";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { getHost } from "./Api/Host";
|
|
||||||
|
|
||||||
const host = () => `http://${getHost()}`;
|
|
||||||
|
|
||||||
export function show() {
|
export function show() {
|
||||||
modal.showModal();
|
modal.showModal();
|
||||||
@@ -32,9 +29,8 @@
|
|||||||
|
|
||||||
playletStateStore.subscribe((value) => {
|
playletStateStore.subscribe((value) => {
|
||||||
authUrl = value?.invidious?.auth_url;
|
authUrl = value?.invidious?.auth_url;
|
||||||
currentInstance =
|
currentInstance = value?.invidious?.invidious_instance || "";
|
||||||
value?.invidious?.invidious_instance || value?.invidious?.instance || "";
|
if (!currentInstance) {
|
||||||
if (currentInstance === `${host()}/playlet-invidious-backend`) {
|
|
||||||
const trFn = get(translate);
|
const trFn = get(translate);
|
||||||
currentInstanceName = trFn("Playlet built-in backend");
|
currentInstanceName = trFn("Playlet built-in backend");
|
||||||
} else {
|
} else {
|
||||||
@@ -69,10 +65,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loginToInvidious() {
|
function loginToInvidious() {
|
||||||
|
if (!currentInstance) {
|
||||||
|
alert("No Invidious instance configured. Please set one in settings.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!authUrl) {
|
if (!authUrl) {
|
||||||
alert("Error with login, please refresh the page.");
|
alert("Error with login, please refresh the page.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.location = authUrl;
|
window.location = authUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ ${JSON.stringify(profilesInfo, null, 2)}
|
|||||||
}
|
}
|
||||||
|
|
||||||
const url = `https://github.com/iBicha/playlet/issues/new?title=${feedbackTitle}&body=${bodyEncoded}`;
|
const url = `https://github.com/iBicha/playlet/issues/new?title=${feedbackTitle}&body=${bodyEncoded}`;
|
||||||
console.log("Github URL length:", url.length);
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
let searchFiltersLabel;
|
let searchFiltersLabel;
|
||||||
|
|
||||||
playletStateStore.subscribe((value) => {
|
playletStateStore.subscribe((value) => {
|
||||||
invidiousApi.instance = value?.invidious?.instance;
|
invidiousApi.setInstance(value?.invidious?.instance);
|
||||||
let userCountryCode = value?.device?.user_country_code;
|
let userCountryCode = value?.device?.user_country_code;
|
||||||
if (!userCountryCode || userCountryCode === "OT") {
|
if (!userCountryCode || userCountryCode === "OT") {
|
||||||
userCountryCode = "US";
|
userCountryCode = "US";
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
let invidiousApi = new InvidiousApi();
|
let invidiousApi = new InvidiousApi();
|
||||||
|
|
||||||
playletStateStore.subscribe((value) => {
|
playletStateStore.subscribe((value) => {
|
||||||
invidiousApi.instance = value?.invidious?.instance;
|
invidiousApi.setInstance(value?.invidious?.instance);
|
||||||
let userCountryCode = value?.device?.user_country_code;
|
let userCountryCode = value?.device?.user_country_code;
|
||||||
if (!userCountryCode || userCountryCode === "OT") {
|
if (!userCountryCode || userCountryCode === "OT") {
|
||||||
userCountryCode = "US";
|
userCountryCode = "US";
|
||||||
|
|||||||
Reference in new issue
Block a user