Export functions instead of using class with only static members
Theres's no need to use a class all members are static and we never instantiate it — it's not Java :D
This commit is contained in:
parent
2385b5f5c8
commit
3c4317504e
|
@ -20,8 +20,8 @@ import * as browser from 'webextension-polyfill';
|
|||
import { MessageKind, RedirectType } from './types';
|
||||
import constants from './constants';
|
||||
import Preferences from './preferences';
|
||||
import InvidiousAPI from './invidious-api';
|
||||
import PeertubeAPI from './peertube-api';
|
||||
import * as InvidiousAPI from './invidious-api';
|
||||
import * as PeertubeAPI from './peertube-api';
|
||||
import { getPeertubeVideoURL } from './util';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import * as _ from 'lodash/fp';
|
||||
import constants from './constants';
|
||||
|
||||
export default class InvidiousAPI {
|
||||
private static async fetchAPI(action: string, params: any) {
|
||||
async function fetchAPI(action: string, params: any) {
|
||||
const paramString = typeof params == 'string'
|
||||
? params
|
||||
: Object.keys(params).map(function(key) {
|
||||
|
@ -17,11 +16,11 @@ export default class InvidiousAPI {
|
|||
));
|
||||
}
|
||||
|
||||
static async getVideo(id: string) {
|
||||
return this.fetchAPI(constants.invidiousAPI.videos, id);
|
||||
|
||||
export async function getVideo(id: string) {
|
||||
return fetchAPI(constants.invidiousAPI.videos, id);
|
||||
}
|
||||
|
||||
static async getChannel(ucid: string) {
|
||||
return this.fetchAPI(constants.invidiousAPI.channels, ucid);
|
||||
}
|
||||
export async function getChannel(ucid: string) {
|
||||
return fetchAPI(constants.invidiousAPI.channels, ucid);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import * as _ from 'lodash/fp';
|
||||
import constants from './constants';
|
||||
|
||||
export default class PeertubeAPI {
|
||||
private static async fetchAPI(path: string, query?: Object) {
|
||||
async function fetchAPI(path: string, query?: Object) {
|
||||
const instance = _.getOr(constants.peertubeAPI.defaultInstance, 'searchInstance', await browser.storage.local.get()).toString();
|
||||
|
||||
let url = `https://${instance}/${constants.peertubeAPI.endpoint}/${path}`;
|
||||
|
@ -19,11 +18,10 @@ export default class PeertubeAPI {
|
|||
));
|
||||
}
|
||||
|
||||
static async getVideo(id: string) {
|
||||
return this.fetchAPI('videos/' + id);
|
||||
export async function getVideo(id: string) {
|
||||
return fetchAPI('videos/' + id);
|
||||
}
|
||||
|
||||
static async searchVideo(query: Object) {
|
||||
return this.fetchAPI('search/videos', query);
|
||||
}
|
||||
export async function searchVideo(query: Object) {
|
||||
return fetchAPI('search/videos', query);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue