lbry-desktop/ui/js/triggers.js
6ea86b96 6abb7bfe92 Loading show page content fast, resolving cost and file info.
Rewards and uploaded/downloaded files currently broken
2017-05-04 11:59:45 -04:00

73 lines
1.5 KiB
JavaScript

import {
shouldFetchTransactions,
shouldGetReceiveAddress,
} from 'selectors/wallet'
import {
shouldFetchFeaturedContent,
shouldFetchDownloadedContent,
shouldFetchPublishedContent,
shouldFetchCurrentUriFileInfo,
shouldFetchCurrentUriCostInfo,
} from 'selectors/content'
import {
doFetchTransactions,
doGetNewAddress,
} from 'actions/wallet'
import {
doFetchFeaturedContent,
doFetchDownloadedContent,
doFetchPublishedContent,
doFetchCurrentUriFileInfo,
doFetchCurrentUriCostInfo,
} from 'actions/content'
const triggers = []
triggers.push({
selector: shouldFetchTransactions,
action: doFetchTransactions,
})
triggers.push({
selector: shouldGetReceiveAddress,
action: doGetNewAddress
})
triggers.push({
selector: shouldFetchFeaturedContent,
action: doFetchFeaturedContent,
})
triggers.push({
selector: shouldFetchDownloadedContent,
action: doFetchDownloadedContent,
})
triggers.push({
selector: shouldFetchPublishedContent,
action: doFetchPublishedContent,
})
triggers.push({
selector: shouldFetchCurrentUriFileInfo,
action: doFetchCurrentUriFileInfo,
})
triggers.push({
selector: shouldFetchCurrentUriCostInfo,
action: doFetchCurrentUriCostInfo,
})
const runTriggers = function() {
triggers.forEach(function(trigger) {
const state = app.store.getState();
const should = trigger.selector(state)
if (trigger.selector(state)) app.store.dispatch(trigger.action())
});
}
module.exports = {
triggers: triggers,
runTriggers: runTriggers
}