Skip to content

Commit

Permalink
chore(vuex): Clean up getter arguments
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Dec 18, 2023
1 parent b33bcf4 commit e415601
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
18 changes: 9 additions & 9 deletions src/store/collectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default {
)
},

collectivePath(state, getters) {
collectivePath(_state, getters) {
return (collective) => {
if (getters.isPublic) {
return `/p/${getters.shareTokenParam}/${encodeURIComponent(collective.name)}`
Expand All @@ -69,7 +69,7 @@ export default {
}
},

currentCollectivePath(state, getters) {
currentCollectivePath(_state, getters) {
return getters.collectivePath(getters.currentCollective)
},

Expand All @@ -86,11 +86,11 @@ export default {
return getters.currentCollective.isPageShare
},

currentCollectiveCanEdit(state, getters) {
currentCollectiveCanEdit(_state, getters) {
return getters.collectiveCanEdit(getters.currentCollective)
},

currentCollectiveCanShare(state, getters) {
currentCollectiveCanShare(_state, getters) {
return getters.collectiveCanShare(getters.currentCollective)
},

Expand Down Expand Up @@ -119,15 +119,15 @@ export default {
return state.shares.filter(s => s.pageId === pageId)
},

isCollectiveAdmin: (state, getters) => (collective) => {
isCollectiveAdmin: (state) => (collective) => {
return collective.level >= memberLevels.LEVEL_ADMIN
},

isCollectiveOwner: (state, getters) => (collective) => {
isCollectiveOwner: (state) => (collective) => {
return collective.level >= memberLevels.LEVEL_OWNER
},

collectiveCanEdit: (state, getters) => (collective) => {
collectiveCanEdit: (_state, getters) => (collective) => {
if (!collective) {
return false
}
Expand All @@ -138,7 +138,7 @@ export default {
return collective.canEdit
},

collectiveCanShare: (state, getters) => (collective) => {
collectiveCanShare: (_state, getters) => (collective) => {
if (!collective) {
return false
}
Expand All @@ -153,7 +153,7 @@ export default {
},

// Return a function (with empty arguments list) to prevent caching the result
randomCollectiveEmoji: (state, getters) => () => {
randomCollectiveEmoji: (_state, getters) => () => {
return randomEmoji(getters.allCollectiveEmojis)
},

Expand Down
8 changes: 4 additions & 4 deletions src/store/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default {
return `/${pagePath}?fileId=${id}`
},

pagePathTitle: (_state, getters) => (page) => {
pagePathTitle: (_state) => (page) => {
const { filePath, fileName, title } = page
const titlePart = fileName !== 'Readme.md' && title
return [filePath, titlePart].filter(Boolean).join('/')
Expand Down Expand Up @@ -214,7 +214,7 @@ export default {

pageParents,

visibleSubpages: (state, getters) => (parentId) => {
visibleSubpages: (_state, getters) => (parentId) => {
return getters.sortedSubpages(parentId)
},

Expand All @@ -230,7 +230,7 @@ export default {
return state.sortBy ? state.sortBy : getters.sortByDefault
},

disableDragndropSortOrMove(state, getters) {
disableDragndropSortOrMove(_state, getters) {
// Disable for readonly collective
return !getters.currentCollectiveCanEdit
// Disable if a page list is loading (e.g. when page move is pending)
Expand Down Expand Up @@ -310,7 +310,7 @@ export default {
return (pageId) => state.pages.find(p => p.id === pageId).subpageOrder
},

subpageOrderIndex(state, getters) {
subpageOrderIndex(_state, getters) {
return (parentId, pageId) => {
const parentSubpageOrder = getters.subpageOrder(parentId)
return parentSubpageOrder.indexOf(pageId)
Expand Down
30 changes: 15 additions & 15 deletions src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ export default new Store({
pageParam: (state) => state.route.params.page,
shareTokenParam: (state) => state.route.params.token,

isIndexPage: (_state, get) =>
get.currentPage.fileName === 'Readme.md',
isIndexPage: (_state, getters) =>
getters.currentPage.fileName === 'Readme.md',

isLandingPage: (_state, get) =>
get.currentCollectiveIsPageShare
isLandingPage: (_state, getters) =>
getters.currentCollectiveIsPageShare
? false
: !get.pageParam || get.pageParam === 'Readme',
: !getters.pageParam || getters.pageParam === 'Readme',

isTemplatePage: (_state, get) =>
get.currentPage.title === 'Template',
isTemplatePage: (_state, getters) =>
getters.currentPage.title === 'Template',

title: (_state, get) =>
get.isLandingPage ? get.currentCollective.name : get.currentPage.title,
title: (_state, getters) =>
getters.isLandingPage ? getters.currentCollective.name : getters.currentPage.title,

isPublic: (_state, get) =>
!!get.shareTokenParam,
isPublic: (_state, getters) =>
!!getters.shareTokenParam,

isTextEdit: (state) => state.textMode === pageModes.MODE_EDIT,
isTextView: (state) => state.textMode === pageModes.MODE_VIEW,
Expand All @@ -62,13 +62,13 @@ export default new Store({
return apiVersion.localeCompare(requiredVersion, undefined, { numeric: true, sensitivity: 'base' }) >= 0
},

useEditorApi(_, get) {
return !!window.OCA?.Text?.createEditor && get.editorApiVersionCheck('1.0')
useEditorApi(_state, getters) {
return !!window.OCA?.Text?.createEditor && getters.editorApiVersionCheck('1.0')
},

editorApiFlags(_, get) {
editorApiFlags(_state, getters) {
const flags = []
if (get.editorApiVersionCheck('1.1')) {
if (getters.editorApiVersionCheck('1.1')) {
flags.push(editorApiReaderFileId)
}
return flags
Expand Down

0 comments on commit e415601

Please sign in to comment.