* Drag and drop files to comment editor to add a file attachment * Using Vue to render comments Since comments now has attachments we need to update the schemas ./manage.py maintenance replace_pillar_node_type_schemas
35 lines
819 B
JavaScript
35 lines
819 B
JavaScript
export { transformPlaceholder } from './placeholder'
|
|
export { prettyDate } from './prettydate'
|
|
export { getCurrentUser, initCurrentUser } from './currentuser'
|
|
|
|
|
|
export function debounced(fn, delay=1000) {
|
|
let timerId;
|
|
return function (...args) {
|
|
if (timerId) {
|
|
clearTimeout(timerId);
|
|
}
|
|
timerId = setTimeout(() => {
|
|
fn(...args);
|
|
timerId = null;
|
|
}, delay);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Extracts error message from error of type String, Error or xhrError
|
|
* @param {*} err
|
|
* @returns {String}
|
|
*/
|
|
export function messageFromError(err){
|
|
if (typeof err === "string") {
|
|
// type String
|
|
return err;
|
|
} else if(typeof err.message === "string") {
|
|
// type Error
|
|
return err.message;
|
|
} else {
|
|
// type xhr probably
|
|
return xhrErrorResponseMessage(err);
|
|
}
|
|
} |