Started adding frontend notifications, fixing firefox file upload bug
This commit is contained in:
33
goTorrentWebUI/node_modules/react-toastify/src/util/EventManager.js
generated
vendored
Normal file
33
goTorrentWebUI/node_modules/react-toastify/src/util/EventManager.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
const eventManager = {
|
||||
eventList: new Map(),
|
||||
|
||||
on(event, callback) {
|
||||
this.eventList.has(event) || this.eventList.set(event, []);
|
||||
|
||||
this.eventList.get(event).push(callback);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
off(event = null) {
|
||||
return this.eventList.delete(event);
|
||||
},
|
||||
|
||||
emit(event, ...args) {
|
||||
if (!this.eventList.has(event)) {
|
||||
/* eslint no-console: 0 */
|
||||
console.warn(
|
||||
`<${event}> Event is not registered. Did you forgot to bind the event ?`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.eventList
|
||||
.get(event)
|
||||
.forEach(callback => setTimeout(() => callback.call(this, ...args), 0));
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
export default eventManager;
|
45
goTorrentWebUI/node_modules/react-toastify/src/util/propValidator.js
generated
vendored
Normal file
45
goTorrentWebUI/node_modules/react-toastify/src/util/propValidator.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
import { isValidElement } from 'react';
|
||||
|
||||
export function isValidDelay(val) {
|
||||
return typeof val === 'number' && !isNaN(val) && val > 0;
|
||||
}
|
||||
|
||||
export function objectValues(obj) {
|
||||
return Object.keys(obj).map(key => obj[key]);
|
||||
}
|
||||
|
||||
function withRequired(fn) {
|
||||
fn.isRequired = function(props, propName, componentName) {
|
||||
const prop = props[propName];
|
||||
|
||||
if (typeof prop === 'undefined') {
|
||||
return new Error(`The prop ${propName} is marked as required in
|
||||
${componentName}, but its value is undefined.`);
|
||||
}
|
||||
|
||||
fn(props, propName, componentName);
|
||||
};
|
||||
return fn;
|
||||
}
|
||||
|
||||
export const falseOrDelay = withRequired((props, propName, componentName) => {
|
||||
const prop = props[propName];
|
||||
|
||||
if (prop !== false && !isValidDelay(prop)) {
|
||||
return new Error(`${componentName} expect ${propName}
|
||||
to be a valid Number > 0 or equal to false. ${prop} given.`);
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
export const falseOrElement = withRequired((props, propName, componentName) => {
|
||||
const prop = props[propName];
|
||||
|
||||
if (prop !== false && !isValidElement(prop)) {
|
||||
return new Error(`${componentName} expect ${propName}
|
||||
to be a valid react element or equal to false. ${prop} given.`);
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
Reference in New Issue
Block a user