mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-11-25 12:45:17 +00:00
feat: added toasts
This commit is contained in:
parent
4d039e3ed0
commit
2ff9cb997e
8 changed files with 47 additions and 16 deletions
|
@ -2,7 +2,7 @@
|
|||
// https://www.youtube.com/youtubei/v1
|
||||
|
||||
import { Http } from "@capacitor-community/http";
|
||||
import { getBetweenStrings } from "./utils";
|
||||
import { getBetweenStrings, delay } from "./utils";
|
||||
import rendererUtils from "./renderers";
|
||||
import constants from "./constants";
|
||||
|
||||
|
@ -44,11 +44,23 @@ class Innertube {
|
|||
this.ErrorCallback(html.data, true);
|
||||
this.ErrorCallback(err, true);
|
||||
}
|
||||
if (this.retry_count >= 10) {
|
||||
this.initAsync();
|
||||
if (this.retry_count < 10) {
|
||||
this.retry_count += 1;
|
||||
if (this.checkErrorCallback)
|
||||
this.ErrorCallback(
|
||||
`retry count: ${this.retry_count}`,
|
||||
false,
|
||||
`An error occurred while trying to init the innertube API. Retrial number: ${this.retry_count}/10`
|
||||
);
|
||||
await delay(5000);
|
||||
await this.initAsync();
|
||||
} else {
|
||||
if (this.checkErrorCallback)
|
||||
this.ErrorCallback("Failed to retrieve Innertube session", true);
|
||||
this.ErrorCallback(
|
||||
"Failed to retrieve Innertube session",
|
||||
true,
|
||||
"An error occurred while retrieving the innertube session. Check the Logs for more information."
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
|
@ -49,6 +49,8 @@ function linkParser(url) {
|
|||
return match && match[7].length == 11 ? match[7] : false;
|
||||
}
|
||||
|
||||
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
|
||||
|
||||
module.exports = {
|
||||
getBetweenStrings,
|
||||
hexToRgb,
|
||||
|
@ -56,4 +58,5 @@ module.exports = {
|
|||
getCpn,
|
||||
getMutationByKey,
|
||||
linkParser,
|
||||
delay,
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@ import constants from "./constants";
|
|||
import rendererUtils from "./renderers";
|
||||
import { Buffer } from "buffer";
|
||||
import iconv from "iconv-lite";
|
||||
import { Toast } from "@capacitor/toast";
|
||||
|
||||
//--- Logger Function ---//
|
||||
function logger(func, data, isError = false) {
|
||||
|
@ -74,9 +75,14 @@ let InnertubeAPI;
|
|||
const innertubeModule = {
|
||||
async getAPI() {
|
||||
if (!InnertubeAPI) {
|
||||
InnertubeAPI = await Innertube.createAsync((message, isError) => {
|
||||
logger(constants.LOGGER_NAMES.innertube, message, isError);
|
||||
});
|
||||
InnertubeAPI = await Innertube.createAsync(
|
||||
(message, isError, shortMessage) => {
|
||||
logger(constants.LOGGER_NAMES.innertube, message, isError);
|
||||
if (shortMessage) {
|
||||
Toast.show({ text: shortMessage });
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return InnertubeAPI;
|
||||
},
|
||||
|
|
|
@ -17,6 +17,7 @@ dependencies {
|
|||
implementation project(':capacitor-share')
|
||||
implementation project(':capacitor-splash-screen')
|
||||
implementation project(':capacitor-status-bar')
|
||||
implementation project(':capacitor-toast')
|
||||
implementation project(':hugotomazi-capacitor-navigation-bar')
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
"pkg": "@capacitor/status-bar",
|
||||
"classpath": "com.capacitorjs.plugins.statusbar.StatusBarPlugin"
|
||||
},
|
||||
{
|
||||
"pkg": "@capacitor/toast",
|
||||
"classpath": "com.capacitorjs.plugins.toast.ToastPlugin"
|
||||
},
|
||||
{
|
||||
"pkg": "@hugotomazi/capacitor-navigation-bar",
|
||||
"classpath": "br.com.tombus.capacitor.plugin.navigationbar.NavigationBarPlugin"
|
||||
|
|
|
@ -26,5 +26,8 @@ project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capa
|
|||
include ':capacitor-status-bar'
|
||||
project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android')
|
||||
|
||||
include ':capacitor-toast'
|
||||
project(':capacitor-toast').projectDir = new File('../node_modules/@capacitor/toast/android')
|
||||
|
||||
include ':hugotomazi-capacitor-navigation-bar'
|
||||
project(':hugotomazi-capacitor-navigation-bar').projectDir = new File('../node_modules/@hugotomazi/capacitor-navigation-bar/android')
|
||||
|
|
|
@ -9,15 +9,16 @@ install! 'cocoapods', :disable_input_output_paths => true
|
|||
def capacitor_pods
|
||||
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
|
||||
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
|
||||
pod 'CapacitorCommunityHttp', :path => '../../node_modules/@capacitor-community/http'
|
||||
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
|
||||
pod 'CapacitorBrowser', :path => '../../node_modules/@capacitor/browser'
|
||||
pod 'CapacitorDevice', :path => '../../node_modules/@capacitor/device'
|
||||
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
|
||||
pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share'
|
||||
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
|
||||
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
|
||||
pod 'HugotomaziCapacitorNavigationBar', :path => '../../node_modules/@hugotomazi/capacitor-navigation-bar'
|
||||
pod 'CapacitorCommunityHttp', :path => '..\..\node_modules\@capacitor-community\http'
|
||||
pod 'CapacitorApp', :path => '..\..\node_modules\@capacitor\app'
|
||||
pod 'CapacitorBrowser', :path => '..\..\node_modules\@capacitor\browser'
|
||||
pod 'CapacitorDevice', :path => '..\..\node_modules\@capacitor\device'
|
||||
pod 'CapacitorHaptics', :path => '..\..\node_modules\@capacitor\haptics'
|
||||
pod 'CapacitorShare', :path => '..\..\node_modules\@capacitor\share'
|
||||
pod 'CapacitorSplashScreen', :path => '..\..\node_modules\@capacitor\splash-screen'
|
||||
pod 'CapacitorStatusBar', :path => '..\..\node_modules\@capacitor\status-bar'
|
||||
pod 'CapacitorToast', :path => '..\..\node_modules\@capacitor\toast'
|
||||
pod 'HugotomaziCapacitorNavigationBar', :path => '..\..\node_modules\@hugotomazi\capacitor-navigation-bar'
|
||||
end
|
||||
|
||||
target 'App' do
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
"@capacitor/share": "^1.1.2",
|
||||
"@capacitor/splash-screen": "^1.2.2",
|
||||
"@capacitor/status-bar": "^1.0.8",
|
||||
"@capacitor/toast": "^1.0.8",
|
||||
"@hugotomazi/capacitor-navigation-bar": "^1.1.1",
|
||||
"iconv-lite": "^0.6.3"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue