[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
|
||||
|
||||
- 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
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Invidious
|
||||
end if
|
||||
end if
|
||||
|
||||
return m.GetPlayletBuiltinInstance()
|
||||
return PLAYLET_BUILT_IN_INSTANCE
|
||||
end function
|
||||
|
||||
function GetInvidiousInstance() as string
|
||||
@@ -89,15 +89,6 @@ namespace Invidious
|
||||
return m.preferences["invidious.instance"]
|
||||
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
|
||||
if StringUtils.IsNullOrEmpty(videoId)
|
||||
return
|
||||
@@ -742,7 +733,7 @@ namespace Invidious
|
||||
function GetAuthorizeTokenLink() as dynamic
|
||||
instance = m.GetInvidiousInstance()
|
||||
if StringUtils.IsNullOrEmpty(instance)
|
||||
instance = m.GetPlayletBuiltinInstance()
|
||||
return invalid
|
||||
end if
|
||||
|
||||
' 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 { getHost } from "./Host";
|
||||
|
||||
const DISABLE_CACHE = true;
|
||||
|
||||
export class InvidiousApi {
|
||||
public instance: string;
|
||||
static host = () => `http://${getHost()}`
|
||||
|
||||
public endpoints: any;
|
||||
public isLoggedIn: boolean = false;
|
||||
public userCountryCode: string = 'US';
|
||||
private instance: string;
|
||||
|
||||
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) {
|
||||
const url = `${this.instance}/api/v1/search/suggestions?q=${encodeURIComponent(query)}®ion=${this.userCountryCode}`;
|
||||
const response = await fetch(url);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
let invidiousApi = new InvidiousApi();
|
||||
|
||||
playletStateStore.subscribe((value) => {
|
||||
invidiousApi.instance = value?.invidious?.instance;
|
||||
invidiousApi.setInstance(value?.invidious?.instance);
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
import { playletStateStore, translate } from "lib/Stores";
|
||||
import { PlayletApi } from "./Api/PlayletApi";
|
||||
import { get } from "svelte/store";
|
||||
import { getHost } from "./Api/Host";
|
||||
|
||||
const host = () => `http://${getHost()}`;
|
||||
|
||||
export function show() {
|
||||
modal.showModal();
|
||||
@@ -32,9 +29,8 @@
|
||||
|
||||
playletStateStore.subscribe((value) => {
|
||||
authUrl = value?.invidious?.auth_url;
|
||||
currentInstance =
|
||||
value?.invidious?.invidious_instance || value?.invidious?.instance || "";
|
||||
if (currentInstance === `${host()}/playlet-invidious-backend`) {
|
||||
currentInstance = value?.invidious?.invidious_instance || "";
|
||||
if (!currentInstance) {
|
||||
const trFn = get(translate);
|
||||
currentInstanceName = trFn("Playlet built-in backend");
|
||||
} else {
|
||||
@@ -69,10 +65,16 @@
|
||||
}
|
||||
|
||||
function loginToInvidious() {
|
||||
if (!currentInstance) {
|
||||
alert("No Invidious instance configured. Please set one in settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!authUrl) {
|
||||
alert("Error with login, please refresh the page.");
|
||||
return;
|
||||
}
|
||||
|
||||
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}`;
|
||||
console.log("Github URL length:", url.length);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
let searchFiltersLabel;
|
||||
|
||||
playletStateStore.subscribe((value) => {
|
||||
invidiousApi.instance = value?.invidious?.instance;
|
||||
invidiousApi.setInstance(value?.invidious?.instance);
|
||||
let userCountryCode = value?.device?.user_country_code;
|
||||
if (!userCountryCode || userCountryCode === "OT") {
|
||||
userCountryCode = "US";
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
let invidiousApi = new InvidiousApi();
|
||||
|
||||
playletStateStore.subscribe((value) => {
|
||||
invidiousApi.instance = value?.invidious?.instance;
|
||||
invidiousApi.setInstance(value?.invidious?.instance);
|
||||
let userCountryCode = value?.device?.user_country_code;
|
||||
if (!userCountryCode || userCountryCode === "OT") {
|
||||
userCountryCode = "US";
|
||||
|
||||
Reference in new issue
Block a user