mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-11-01 01:12:39 +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
|
// https://www.youtube.com/youtubei/v1
|
||||||
|
|
||||||
import { Http } from "@capacitor-community/http";
|
import { Http } from "@capacitor-community/http";
|
||||||
import { getBetweenStrings } from "./utils";
|
import { getBetweenStrings, delay } from "./utils";
|
||||||
import rendererUtils from "./renderers";
|
import rendererUtils from "./renderers";
|
||||||
import constants from "./constants";
|
import constants from "./constants";
|
||||||
|
|
||||||
|
@ -44,11 +44,23 @@ class Innertube {
|
||||||
this.ErrorCallback(html.data, true);
|
this.ErrorCallback(html.data, true);
|
||||||
this.ErrorCallback(err, true);
|
this.ErrorCallback(err, true);
|
||||||
}
|
}
|
||||||
if (this.retry_count >= 10) {
|
if (this.retry_count < 10) {
|
||||||
this.initAsync();
|
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 {
|
} else {
|
||||||
if (this.checkErrorCallback)
|
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) {
|
} catch (error) {
|
||||||
|
|
|
@ -49,6 +49,8 @@ function linkParser(url) {
|
||||||
return match && match[7].length == 11 ? match[7] : false;
|
return match && match[7].length == 11 ? match[7] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getBetweenStrings,
|
getBetweenStrings,
|
||||||
hexToRgb,
|
hexToRgb,
|
||||||
|
@ -56,4 +58,5 @@ module.exports = {
|
||||||
getCpn,
|
getCpn,
|
||||||
getMutationByKey,
|
getMutationByKey,
|
||||||
linkParser,
|
linkParser,
|
||||||
|
delay,
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@ import constants from "./constants";
|
||||||
import rendererUtils from "./renderers";
|
import rendererUtils from "./renderers";
|
||||||
import { Buffer } from "buffer";
|
import { Buffer } from "buffer";
|
||||||
import iconv from "iconv-lite";
|
import iconv from "iconv-lite";
|
||||||
|
import { Toast } from "@capacitor/toast";
|
||||||
|
|
||||||
//--- Logger Function ---//
|
//--- Logger Function ---//
|
||||||
function logger(func, data, isError = false) {
|
function logger(func, data, isError = false) {
|
||||||
|
@ -74,9 +75,14 @@ let InnertubeAPI;
|
||||||
const innertubeModule = {
|
const innertubeModule = {
|
||||||
async getAPI() {
|
async getAPI() {
|
||||||
if (!InnertubeAPI) {
|
if (!InnertubeAPI) {
|
||||||
InnertubeAPI = await Innertube.createAsync((message, isError) => {
|
InnertubeAPI = await Innertube.createAsync(
|
||||||
|
(message, isError, shortMessage) => {
|
||||||
logger(constants.LOGGER_NAMES.innertube, message, isError);
|
logger(constants.LOGGER_NAMES.innertube, message, isError);
|
||||||
});
|
if (shortMessage) {
|
||||||
|
Toast.show({ text: shortMessage });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return InnertubeAPI;
|
return InnertubeAPI;
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,6 +17,7 @@ dependencies {
|
||||||
implementation project(':capacitor-share')
|
implementation project(':capacitor-share')
|
||||||
implementation project(':capacitor-splash-screen')
|
implementation project(':capacitor-splash-screen')
|
||||||
implementation project(':capacitor-status-bar')
|
implementation project(':capacitor-status-bar')
|
||||||
|
implementation project(':capacitor-toast')
|
||||||
implementation project(':hugotomazi-capacitor-navigation-bar')
|
implementation project(':hugotomazi-capacitor-navigation-bar')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
"pkg": "@capacitor/status-bar",
|
"pkg": "@capacitor/status-bar",
|
||||||
"classpath": "com.capacitorjs.plugins.statusbar.StatusBarPlugin"
|
"classpath": "com.capacitorjs.plugins.statusbar.StatusBarPlugin"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"pkg": "@capacitor/toast",
|
||||||
|
"classpath": "com.capacitorjs.plugins.toast.ToastPlugin"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"pkg": "@hugotomazi/capacitor-navigation-bar",
|
"pkg": "@hugotomazi/capacitor-navigation-bar",
|
||||||
"classpath": "br.com.tombus.capacitor.plugin.navigationbar.NavigationBarPlugin"
|
"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'
|
include ':capacitor-status-bar'
|
||||||
project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android')
|
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'
|
include ':hugotomazi-capacitor-navigation-bar'
|
||||||
project(':hugotomazi-capacitor-navigation-bar').projectDir = new File('../node_modules/@hugotomazi/capacitor-navigation-bar/android')
|
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
|
def capacitor_pods
|
||||||
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
|
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
|
||||||
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
|
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
|
||||||
pod 'CapacitorCommunityHttp', :path => '../../node_modules/@capacitor-community/http'
|
pod 'CapacitorCommunityHttp', :path => '..\..\node_modules\@capacitor-community\http'
|
||||||
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
|
pod 'CapacitorApp', :path => '..\..\node_modules\@capacitor\app'
|
||||||
pod 'CapacitorBrowser', :path => '../../node_modules/@capacitor/browser'
|
pod 'CapacitorBrowser', :path => '..\..\node_modules\@capacitor\browser'
|
||||||
pod 'CapacitorDevice', :path => '../../node_modules/@capacitor/device'
|
pod 'CapacitorDevice', :path => '..\..\node_modules\@capacitor\device'
|
||||||
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
|
pod 'CapacitorHaptics', :path => '..\..\node_modules\@capacitor\haptics'
|
||||||
pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share'
|
pod 'CapacitorShare', :path => '..\..\node_modules\@capacitor\share'
|
||||||
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
|
pod 'CapacitorSplashScreen', :path => '..\..\node_modules\@capacitor\splash-screen'
|
||||||
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
|
pod 'CapacitorStatusBar', :path => '..\..\node_modules\@capacitor\status-bar'
|
||||||
pod 'HugotomaziCapacitorNavigationBar', :path => '../../node_modules/@hugotomazi/capacitor-navigation-bar'
|
pod 'CapacitorToast', :path => '..\..\node_modules\@capacitor\toast'
|
||||||
|
pod 'HugotomaziCapacitorNavigationBar', :path => '..\..\node_modules\@hugotomazi\capacitor-navigation-bar'
|
||||||
end
|
end
|
||||||
|
|
||||||
target 'App' do
|
target 'App' do
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"@capacitor/share": "^1.1.2",
|
"@capacitor/share": "^1.1.2",
|
||||||
"@capacitor/splash-screen": "^1.2.2",
|
"@capacitor/splash-screen": "^1.2.2",
|
||||||
"@capacitor/status-bar": "^1.0.8",
|
"@capacitor/status-bar": "^1.0.8",
|
||||||
|
"@capacitor/toast": "^1.0.8",
|
||||||
"@hugotomazi/capacitor-navigation-bar": "^1.1.1",
|
"@hugotomazi/capacitor-navigation-bar": "^1.1.1",
|
||||||
"iconv-lite": "^0.6.3"
|
"iconv-lite": "^0.6.3"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue