mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-08 08:17:31 +00:00
Compare commits
No commits in common. "67713c60d4bc108ddbdbb57b20ba300d8a3db7a2" and "f4306ad1c3523784139ab153cff729c158dea187" have entirely different histories.
67713c60d4
...
f4306ad1c3
@ -13,7 +13,7 @@ class PluginLocalStorageApi {
|
||||
required this.pluginName,
|
||||
}) {
|
||||
runtime.onMessage("LocalStorage.getItem", (args) {
|
||||
final key = args[0]["key"];
|
||||
final key = args[0];
|
||||
final value = getItem(key);
|
||||
runtime.evaluate(
|
||||
"""
|
||||
|
||||
@ -70,11 +70,4 @@ class PluginSetIntervalApi {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
for (var timer in _timers.values) {
|
||||
timer.cancel();
|
||||
}
|
||||
_timers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ class PluginTotpGenerator {
|
||||
|
||||
runtime.evaluate(
|
||||
"""
|
||||
eventEmitter.emit('TotpGenerator.generate', '$otp');
|
||||
eventEmitter.emit('Totp.generate', '$otp');
|
||||
""",
|
||||
);
|
||||
});
|
||||
|
||||
@ -49,17 +49,13 @@ class PluginWebViewApi {
|
||||
}
|
||||
showWebView(
|
||||
url: args[0]["url"] as String,
|
||||
initialSettings: args[0]["initialSettings"] != null
|
||||
? WebviewInitialSettings.fromJson(
|
||||
args[0]["initialSettings"],
|
||||
)
|
||||
: null,
|
||||
initialSettings: WebviewInitialSettings.fromJson(
|
||||
args[0]["initialSettings"],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Webview? webviewWindow;
|
||||
|
||||
Future showWebView({
|
||||
required String url,
|
||||
WebviewInitialSettings? initialSettings,
|
||||
@ -121,8 +117,6 @@ class PluginWebViewApi {
|
||||
),
|
||||
);
|
||||
|
||||
webviewWindow = webview;
|
||||
|
||||
runtime.onMessage("WebView.close", (args) {
|
||||
webview.close();
|
||||
});
|
||||
@ -140,7 +134,7 @@ class PluginWebViewApi {
|
||||
"domain": e.domain,
|
||||
"path": e.path,
|
||||
};
|
||||
}).toList();
|
||||
});
|
||||
|
||||
runtime.evaluate(
|
||||
"""
|
||||
@ -163,9 +157,4 @@ class PluginWebViewApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
webviewWindow?.close();
|
||||
webviewWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,6 +61,19 @@ class MetadataApiSignature {
|
||||
},
|
||||
);
|
||||
|
||||
final res = runtime.evaluate(
|
||||
"""
|
||||
;$libraryCode;
|
||||
const metadataApi = new MetadataApi();
|
||||
""",
|
||||
);
|
||||
|
||||
if (res.isError) {
|
||||
AppLogger.reportError(
|
||||
"Error evaluating code: $libraryCode\n${res.rawResult}",
|
||||
);
|
||||
}
|
||||
|
||||
// Create all the PluginAPIs after library code is evaluated
|
||||
final localStorageApi = PluginLocalStorageApi(
|
||||
runtime: runtime,
|
||||
@ -80,26 +93,12 @@ class MetadataApiSignature {
|
||||
setIntervalApi,
|
||||
);
|
||||
|
||||
final res = runtime.evaluate(
|
||||
"""
|
||||
;$libraryCode;
|
||||
const metadataApi = new MetadataApi();
|
||||
""",
|
||||
);
|
||||
metadataApi._signatureFlags = await metadataApi._getSignatureFlags();
|
||||
|
||||
if (res.isError) {
|
||||
AppLogger.reportError(
|
||||
"Error evaluating code: $libraryCode\n${res.rawResult}",
|
||||
);
|
||||
}
|
||||
|
||||
return metadataApi;
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
setIntervalApi.dispose();
|
||||
webViewApi.dispose();
|
||||
runtime.dispose();
|
||||
}
|
||||
|
||||
@ -120,7 +119,7 @@ class MetadataApiSignature {
|
||||
$method(...${args != null ? jsonEncode(args) : "[]"})
|
||||
.then((res) => {
|
||||
try {
|
||||
sendMessage("$method", res ? JSON.stringify(res) : "[]");
|
||||
sendMessage("$method", JSON.stringify(res));
|
||||
} catch (e) {
|
||||
console.error("Failed to send message in $method.then: ", `\${e.toString()}\n\${e.stack.toString()}`);
|
||||
}
|
||||
@ -157,10 +156,6 @@ class MetadataApiSignature {
|
||||
await invoke("metadataApi.authenticate");
|
||||
}
|
||||
|
||||
Future<void> logout() async {
|
||||
await invoke("metadataApi.logout");
|
||||
}
|
||||
|
||||
// ----- Track ------
|
||||
Future<SpotubeTrackObject> getTrack(String id) async {
|
||||
final result = await invoke("metadataApi.getTrack", [id]);
|
||||
@ -502,12 +497,6 @@ class MetadataApiSignature {
|
||||
}
|
||||
|
||||
// ----- User ------
|
||||
Future<SpotubeUserObject> getMe() async {
|
||||
final res = await invoke("metadataApi.getMe");
|
||||
|
||||
return SpotubeUserObject.fromJson(res);
|
||||
}
|
||||
|
||||
Future<void> followArtist(String userId, String artistId) async {
|
||||
await invoke("metadataApi.followArtist", [userId, artistId]);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user