Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
locationPicked = ({ placeId, timezone }) => {
this.setState({ placeId, timezone, notFilled: false })
}
photoModeChanged = photoMode => {
this.setState({ photoMode })
}
twitterChanged = e => {
const twitterHandle = e.target.value
this.setState({ twitterHandle })
// Fetch avatar in the background
this.getAvatar(twitterHandle)
}
getAvatar = debounce(async twitter => {
if (typeof window === 'undefined' || !twitter) {
this.setState({ photoUrl: '', photoCloudObject: null })
return
}
const result = await fetch(`${restEndpoint}/twivatar/${twitter}`)
// Image not found
if (!result.ok) {
this.setState({ photoUrl: '', photoCloudObject: null })
return
}
this.setState({
photoUrl: `${restEndpoint}/twivatar/${twitter}`,
photoCloudObject: null,
function getReleaseSearch() {
if (search.current !== null) {
return search.current
}
const debouncedMark = debounce(value => {
if (mark.current) {
mark.current.unmark()
}
mark.current = new Mark(document.querySelectorAll('.release'))
mark.current.mark(value)
}, 100)
search.current = value => {
setSearchValue(value)
debouncedMark(value)
}
return search.current
}
function syncPositionWith(syncElement) {
removeScrollListeners();
const afterScrollFinishRecheck =
debounce(() => this.onScroll(syncElement), AFTER_SCROLL_RECHECK_INTERVAL);
const sidebarScrollListener = debounce(() => {
this.onScroll(syncElement);
afterScrollFinishRecheck();
}, DEBOUNCE_INTERVAL);
this.waitForNonZeroHeight(syncElement).then(sidebarScrollListener);
$window.addEventListener('scroll', sidebarScrollListener);
removeScrollListener.push(() => {
$window.removeEventListener('scroll', sidebarScrollListener);
});
removeScrollListener.push(scope.$watch('show', sidebarScrollListener));
removeScrollListener.push(scope.$on('rgPlaceUnder:sync', sidebarScrollListener));
if (search.current !== null) {
return search.current
}
const releaseSearch = new Search(['node', 'id'])
releaseSearch.searchIndex = new UnorderedSearchIndex()
releaseSearch.addIndex(['node', 'name'])
releaseSearch.addIndex(['node', 'tagName'])
releaseSearch.addIndex([
'node',
'childGithubReleaseBody',
'childMarkdownRemark',
'plainText',
])
releaseSearch.addDocuments(edges)
const debouncedReleaseSearch = debounce(value => {
setReleases(!!value ? releaseSearch.search(value) : edges)
}, 100)
search.current = value => {
setSearchValue(value)
debouncedReleaseSearch(value)
}
return search.current
}
setupRequestHandler(delay) {
const needDelay = typeof delay === 'number';
const hasDelay = this.requestData !== this.requestHandler;
if (!this.requestData || hasDelay !== needDelay) {
if (needDelay) {
this.requestData = debounce(this.requestHandler, delay);
} else {
this.requestData = this.requestHandler;
}
}
}
const createOnChangeDebounced = () => {
return debounce((codeMirrorDocument, change) => {
if (change !== 'setValue') {
onChange(codeMirrorDocument.getValue())
}
}, DEBOUNCE_TIME)
}
if (existingButton) existingButton.remove()
container.append(toTopButton)
hideButton()
return toTopButton
}
function clickHandler(event) {
event.preventDefault()
hideButton()
animatedScrollTop()
}
const debouncedScrollHandler = debounce(() => {
if (scrollManager.getScrollTop() > MAIN_TOP) {
showButton()
} else {
hideButton()
}
}, SCROLL_DEBOUNCE_WAIT)
function scrollHandler() {
hideButton()
debouncedScrollHandler()
}
function showButton() {
if (!isHidden) return
isHidden = false
function syncPositionWith(syncElement) {
removeScrollListeners();
const afterScrollFinishRecheck =
debounce(() => this.onScroll(syncElement), AFTER_SCROLL_RECHECK_INTERVAL);
const sidebarScrollListener = debounce(() => {
this.onScroll(syncElement);
afterScrollFinishRecheck();
}, DEBOUNCE_INTERVAL);
this.waitForNonZeroHeight(syncElement).then(sidebarScrollListener);
$window.addEventListener('scroll', sidebarScrollListener);
removeScrollListener.push(() => {
$window.removeEventListener('scroll', sidebarScrollListener);
});
removeScrollListener.push(scope.$watch('show', sidebarScrollListener));
removeScrollListener.push(scope.$on('rgPlaceUnder:sync', sidebarScrollListener));
scope.stickToSelector = iAttrs.stickTo;
//Shortcut for placing under table toolbar
if (iAttrs.stickToToolbar !== undefined) {
scope.stickToSelector = '.ring-table__toolbar';
}
const scrollableHeader = element.querySelector('.ring-table__header:not(.ring-table__header_sticky)');
const fixedHeader = element.querySelector('.ring-table__header_sticky');
const toolbarFixed = () => stickToElement.querySelector(`.${TOOLBAR_FIXED_CLASSNAME}`) !== null;
/**
* Sync header columns width with real table
*/
const resizeFixedHeader = debounce(() => {
fixedHeader.style.width = `${scrollableHeader.offsetWidth}px`;
const titles = [...fixedHeader.querySelectorAll('.ring-table__title')];
titles.forEach((titleElement, index) => {
const targetHeaderTitle =
scrollableHeader.querySelectorAll('.ring-table__title')[index];
titleElement.style.width = getStyles(targetHeaderTitle).width;
});
}, HEADER_RESIZE_DEBOUNCE, true);
/**
* Toggle headers on scroll. Also resize header columns with some big interval
*/
const scrollListener = debounce(() => {
if (toolbarFixed()) {
export default context => {
const { requireModules, elementCollection } = context
const { scrollManager } = requireModules([ 'scrollManager' ])
const onScroll = debounce(() => {
if (!hasReachedBottom()) return
if (isLoading()) return
if (!isButtonVisible()) return
loadMore()
}, SCROLL_DEBOUNCE_WAIT)
elementCollection.add({
buttonMore: '#pagination-more',
})
function loadMore() {
elementCollection.get('buttonMore').click()
}
function hasReachedBottom() {