diff --git a/src/routes/_components/compose/ComposeAutosuggest.html b/src/routes/_components/compose/ComposeAutosuggest.html index eaeddfa2..5dda60ba 100644 --- a/src/routes/_components/compose/ComposeAutosuggest.html +++ b/src/routes/_components/compose/ComposeAutosuggest.html @@ -40,7 +40,7 @@ \ No newline at end of file + diff --git a/src/routes/_store/computations/autosuggestComputations.js b/src/routes/_store/computations/autosuggestComputations.js index 7fd719e5..7384b160 100644 --- a/src/routes/_store/computations/autosuggestComputations.js +++ b/src/routes/_store/computations/autosuggestComputations.js @@ -1,4 +1,4 @@ -import get from 'lodash-es/get' +import { get } from '../../_utils/lodash-lite' const MIN_PREFIX_LENGTH = 1 const ACCOUNT_SEARCH_REGEX = new RegExp(`(?:\\s|^)(@\\S{${MIN_PREFIX_LENGTH},})$`) diff --git a/src/routes/_store/computations/timelineComputations.js b/src/routes/_store/computations/timelineComputations.js index 01943089..45820cb9 100644 --- a/src/routes/_store/computations/timelineComputations.js +++ b/src/routes/_store/computations/timelineComputations.js @@ -1,4 +1,4 @@ -import get from 'lodash-es/get' +import { get } from '../../_utils/lodash-lite' function computeForTimeline (store, key, defaultValue) { store.compute(key, diff --git a/src/routes/_store/mixins/timelineMixins.js b/src/routes/_store/mixins/timelineMixins.js index 159283d9..6be04cf9 100644 --- a/src/routes/_store/mixins/timelineMixins.js +++ b/src/routes/_store/mixins/timelineMixins.js @@ -1,5 +1,4 @@ -import pickBy from 'lodash-es/pickBy' -import get from 'lodash-es/get' +import { pickBy, get } from '../../_utils/lodash-lite' export function timelineMixins (Store) { Store.prototype.setForTimeline = function (instanceName, timelineName, obj) { @@ -21,11 +20,6 @@ export function timelineMixins (Store) { return get(root, [instanceName, timelineName]) } - Store.prototype.getForCurrentTimeline = function (key) { - let { currentInstance, currentTimeline } = this.get() - return this.getForTimeline(currentInstance, currentTimeline, key) - } - Store.prototype.getAllTimelineData = function (instanceName, key) { let root = this.get()[`timelineData_${key}`] || {} return root[instanceName] || {} diff --git a/src/routes/_utils/lodash-lite.js b/src/routes/_utils/lodash-lite.js new file mode 100644 index 00000000..873cdfcf --- /dev/null +++ b/src/routes/_utils/lodash-lite.js @@ -0,0 +1,23 @@ +// Some functions from Lodash that are a bit heavyweight and which +// we can just do in idiomatic ES2015+ + +export function get (obj, keys, defaultValue) { + for (let key of keys) { + if (obj && key in obj) { + obj = obj[key] + } else { + return defaultValue + } + } + return obj +} + +export function pickBy (obj, predicate) { + let res = {} + for (let [key, value] of Object.entries(obj)) { + if (predicate(value, key)) { + res[key] = value + } + } + return res +} diff --git a/webpack/client.config.js b/webpack/client.config.js index 52af84ac..e4eefedb 100644 --- a/webpack/client.config.js +++ b/webpack/client.config.js @@ -47,9 +47,7 @@ module.exports = { /\/_database\/database\.js$/, // this version plays nicer with IDEs './database.prod.js' ), - new LodashModuleReplacementPlugin({ - paths: true - }), + new LodashModuleReplacementPlugin(), new CircularDependencyPlugin({ exclude: /node_modules/, failOnError: true,