mirror of https://github.com/Lissy93/dashy.git
Use item visibility to filterTiles
This commit is contained in:
parent
04774c23ed
commit
c33e03f4f5
|
@ -5,6 +5,7 @@
|
||||||
import Defaults, { localStorageKeys, iconCdns } from '@/utils/defaults';
|
import Defaults, { localStorageKeys, iconCdns } from '@/utils/defaults';
|
||||||
import Keys from '@/utils/StoreMutations';
|
import Keys from '@/utils/StoreMutations';
|
||||||
import { searchTiles } from '@/utils/Search';
|
import { searchTiles } from '@/utils/Search';
|
||||||
|
import { checkItemVisibility } from '@/utils/CheckItemVisibility';
|
||||||
|
|
||||||
const HomeMixin = {
|
const HomeMixin = {
|
||||||
props: {
|
props: {
|
||||||
|
@ -64,8 +65,11 @@ const HomeMixin = {
|
||||||
},
|
},
|
||||||
/* Returns only the tiles that match the users search query */
|
/* Returns only the tiles that match the users search query */
|
||||||
filterTiles(allTiles) {
|
filterTiles(allTiles) {
|
||||||
if (!allTiles) return [];
|
if (!allTiles) {
|
||||||
return searchTiles(allTiles, this.searchValue);
|
return [];
|
||||||
|
}
|
||||||
|
const visibleTiles = allTiles.filter((tile) => checkItemVisibility(tile));
|
||||||
|
return searchTiles(visibleTiles, this.searchValue);
|
||||||
},
|
},
|
||||||
/* Checks if any sections or items use icons from a given CDN */
|
/* Checks if any sections or items use icons from a given CDN */
|
||||||
checkIfIconLibraryNeeded(prefix) {
|
checkIfIconLibraryNeeded(prefix) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ const isItemVisibleToUser = (displayData, currentUser, isGuest) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Putting it all together, the function to export */
|
/* Putting it all together, the function to export */
|
||||||
const checkItemVisibility = (item) => {
|
export const checkItemVisibility = (item) => {
|
||||||
const currentUser = getCurrentUser(); // Get current user object
|
const currentUser = getCurrentUser(); // Get current user object
|
||||||
const isGuest = isLoggedInAsGuest(); // Check if current user is a guest
|
const isGuest = isLoggedInAsGuest(); // Check if current user is a guest
|
||||||
const displayData = item.displayData || {};
|
const displayData = item.displayData || {};
|
||||||
|
|
Loading…
Reference in New Issue