aboutsummaryrefslogtreecommitdiff
path: root/src/services/bookmark_folders_fetcher/bookmark_folders_fetcher.service.js
blob: 2181ab67bfe0ebb520598f0b781d1eab96e26b7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import apiService from '../api/api.service.js'
import { promiseInterval } from '../promise_interval/promise_interval.js'

const fetchAndUpdate = ({ store, credentials }) => {
  return apiService.fetchBookmarkFolders({ credentials })
    .then(bookmarkFolders => {
      store.commit('setBookmarkFolders', bookmarkFolders)
    }, () => {})
    .catch(() => {})
}

const startFetching = ({ credentials, store }) => {
  const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
  boundFetchAndUpdate()
  return promiseInterval(boundFetchAndUpdate, 240000)
}

const bookmarkFoldersFetcher = {
  startFetching
}

export default bookmarkFoldersFetcher