Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ₯… Adds safty check when displayData undefined

Alicia Sykese07f2988bc9d
diff --git a/src/components/LinkItems/Section.vue b/src/components/LinkItems/Section.vue
index 335f83a7..e5e6881f 100644
--- a/src/components/LinkItems/Section.vue
+++ b/src/components/LinkItems/Section.vue
@@ -128,7 +128,7 @@ export default {
widgets: Array,
index: Number,
isWide: Boolean,
- activeColCount: String,
+ activeColCount: Number,
},
components: {
Collapsable,
@@ -211,7 +211,9 @@ export default {
return styles;
},
effectiveColsSpan() {
- return Math.min(this.activeColCount, this.displayData.cols);
+ const { cols } = this.displayData;
+ if (!cols) return cols;
+ return Math.min(this.activeColCount, cols);
},
},
methods: {
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 63c304b0..ca73a8bb 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -85,7 +85,7 @@ export default {
layout: '',
itemSizeBound: '',
addNewSectionOpen: false,
- activeColCount: '1',
+ activeColCount: 1,
}),
computed: {
singleSectionView() {
@@ -179,8 +179,10 @@ export default {
const { sectionsContainer } = this.$refs;
if (!sectionsContainer) return;
const cs = getComputedStyle(sectionsContainer);
- const varVal = cs.getPropertyValue('--col-count').trim();
- this.activeColCount = varVal;
+ const varVal = parseInt(cs.getPropertyValue('--col-count'), 10);
+ if (!Number.isNaN(varVal) && varVal > 0) {
+ this.activeColCount = varVal;
+ }
},
},
mounted() {
@@ -189,6 +191,10 @@ export default {
this.layout = this.layoutOrientation;
this.itemSizeBound = this.iconSize;
this.readActiveColCount();
+ window.addEventListener('resize', this.readActiveColCount);
+ },
+ beforeDestroy() {
+ window.removeEventListener('resize', this.readActiveColCount);
},
};
</script>