mirror of https://github.com/nextcloud/bookmarks
parent
dbc8461d10
commit
5e3b6a2792
|
@ -138,7 +138,7 @@ export default {
|
|||
key: 'sorting',
|
||||
value: e.target.value
|
||||
})
|
||||
this.$router.push({ name: 'home' })
|
||||
await this.$store.dispatch(actions.FETCH_PAGE)
|
||||
},
|
||||
onChangeViewMode(e) {},
|
||||
onRssClick(e) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import BookmarksList from './BookmarksList'
|
|||
import Breadcrumbs from './Breadcrumbs'
|
||||
import SidebarBookmark from './SidebarBookmark'
|
||||
import MoveDialog from './MoveDialog'
|
||||
import { actions } from '../store/'
|
||||
import { actions, mutations } from '../store/'
|
||||
|
||||
export default {
|
||||
name: 'ViewPrivate',
|
||||
|
@ -55,13 +55,17 @@ export default {
|
|||
$route: 'onRoute'
|
||||
},
|
||||
|
||||
created() {
|
||||
this.reloadSettings()
|
||||
this.reloadTags()
|
||||
this.reloadFolders()
|
||||
this.onRoute()
|
||||
async created() {
|
||||
document.addEventListener('scroll', this.onScroll)
|
||||
this.search = new OCA.Search(this.onSearch, this.onResetSearch)
|
||||
// set loading indicator
|
||||
this.$store.commit(mutations.FETCH_START, { type: 'bookmarks' })
|
||||
await Promise.all([
|
||||
this.reloadSettings(),
|
||||
this.reloadTags(),
|
||||
this.reloadFolders()
|
||||
])
|
||||
this.onRoute()
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
@ -94,14 +98,14 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
reloadTags() {
|
||||
this.$store.dispatch(actions.LOAD_TAGS)
|
||||
async reloadTags() {
|
||||
return this.$store.dispatch(actions.LOAD_TAGS)
|
||||
},
|
||||
reloadFolders() {
|
||||
this.$store.dispatch(actions.LOAD_FOLDERS)
|
||||
async reloadFolders() {
|
||||
return this.$store.dispatch(actions.LOAD_FOLDERS)
|
||||
},
|
||||
reloadSettings() {
|
||||
this.$store.dispatch(actions.LOAD_SETTINGS)
|
||||
async reloadSettings() {
|
||||
return this.$store.dispatch(actions.LOAD_SETTINGS)
|
||||
},
|
||||
|
||||
onSearch(search) {
|
||||
|
|
|
@ -321,11 +321,17 @@ export default {
|
|||
},
|
||||
|
||||
[actions.LOAD_FOLDERS]({ commit, dispatch, state }) {
|
||||
if (state.loading.bookmarks) return
|
||||
commit(mutations.FETCH_START, { type: 'folders' })
|
||||
let canceled = false
|
||||
commit(mutations.FETCH_START, {
|
||||
type: 'folders',
|
||||
cancel: () => {
|
||||
canceled = true
|
||||
}
|
||||
})
|
||||
return axios
|
||||
.get(url('/folder'), { params: {} })
|
||||
.then(response => {
|
||||
if (canceled) return
|
||||
const {
|
||||
data: { data, status }
|
||||
} = response
|
||||
|
@ -550,10 +556,13 @@ export default {
|
|||
})
|
||||
},
|
||||
|
||||
[actions.SET_SETTING]({ commit, dispatch, state }, { key, value }) {
|
||||
commit(mutations.SET_SETTING, key, value)
|
||||
if (key === 'viewMode' && state.viewMode !== value) {
|
||||
commit(mutations.SET_VIEW_MODE, value)
|
||||
async [actions.SET_SETTING]({ commit, dispatch, state }, { key, value }) {
|
||||
await commit(mutations.SET_SETTING, { key, value })
|
||||
if (key === 'viewMode') {
|
||||
await commit(mutations.SET_VIEW_MODE, value)
|
||||
}
|
||||
if (key === 'sorting') {
|
||||
await commit(mutations.RESET_PAGE)
|
||||
}
|
||||
return axios
|
||||
.post(url(`/settings/${key}`), {
|
||||
|
@ -571,13 +580,16 @@ export default {
|
|||
[actions.LOAD_SETTING]({ commit, dispatch, state }, key) {
|
||||
return axios
|
||||
.get(url(`/settings/${key}`))
|
||||
.then(response => {
|
||||
.then(async response => {
|
||||
const {
|
||||
data: { [key]: value }
|
||||
} = response
|
||||
commit(mutations.SET_SETTING, { key, value })
|
||||
if (key === 'viewMode' && state.viewMode !== value) {
|
||||
commit(mutations.SET_VIEW_MODE, value)
|
||||
await commit(mutations.SET_SETTING, { key, value })
|
||||
if (key === 'viewMode') {
|
||||
await commit(mutations.SET_VIEW_MODE, value)
|
||||
}
|
||||
if (key === 'sorting') {
|
||||
await commit(mutations.RESET_PAGE)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
|
|
|
@ -14,6 +14,7 @@ export const mutations = {
|
|||
REMOVE_ALL_BOOKMARK: 'REMOVE_ALL_BOOKMARK',
|
||||
SET_TAGS: 'SET_TAGS',
|
||||
INCREMENT_PAGE: 'INCREMENT_PAGE',
|
||||
RESET_PAGE: 'RESET_PAGE',
|
||||
SET_QUERY: 'SET_QUERY',
|
||||
SET_SORTBY: 'SET_SORTBY',
|
||||
FETCH_START: 'FETCH_START',
|
||||
|
@ -107,6 +108,11 @@ export default {
|
|||
[mutations.INCREMENT_PAGE](state) {
|
||||
Vue.set(state.fetchState, 'page', state.fetchState.page + 1)
|
||||
},
|
||||
[mutations.RESET_PAGE](state) {
|
||||
state.bookmarks = []
|
||||
state.bookmarksById = {}
|
||||
Vue.set(state.fetchState, 'page', 0)
|
||||
},
|
||||
[mutations.SET_QUERY](state, query) {
|
||||
state.bookmarks = []
|
||||
state.bookmarksById = {}
|
||||
|
@ -133,5 +139,5 @@ function sortFolders(folders) {
|
|||
folders.forEach(folder => {
|
||||
folder.children = sortFolders(folder.children)
|
||||
})
|
||||
return folders.sort((a, b) => a.title > b.title ? 1 : -1)
|
||||
return folders.sort((a, b) => (a.title > b.title ? 1 : -1))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue