Skip to content

Commit

Permalink
Merge pull request #24 from grantjbutler/pinia
Browse files Browse the repository at this point in the history
Migrate from Vuex to Pinia
  • Loading branch information
grantjbutler authored Feb 12, 2022
2 parents c8b5394 + b16a319 commit d3a02c7
Show file tree
Hide file tree
Showing 20 changed files with 281 additions and 291 deletions.
94 changes: 71 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"lodash": "^4.17.21",
"obs-websocket-js": "^4.0.3",
"on-change": "^4.0.0",
"pinia": "^2.0.11",
"uuid": "^8.3.2",
"vue": "3.2.30",
"vuex": "^4.0.2"
"vue": "3.2.30"
}
}
8 changes: 4 additions & 4 deletions packages/renderer/src/components/ConnectionState.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

<script lang="ts" setup>
import { computed } from 'vue';
import { useStore } from '/@/store/app';
import { useObsStore } from '/@/store/obs';
import { OBSConnectionState } from '../../../shared/src/obs';
const props = defineProps<{
size: 'small' | 'medium'
}>();
const store = useStore();
const store = useObsStore();
const sizeClasses = computed(() => {
switch (props.size) {
Expand All @@ -29,7 +29,7 @@ const sizeClasses = computed(() => {
// eslint-disable-next-line vue/return-in-computed-property
const backgroundColor = computed(() => {
switch (store.state.connectionState) {
switch (store.connectionState) {
case OBSConnectionState.Connecting:
return 'bg-yellow-500';
case OBSConnectionState.Connected:
Expand All @@ -41,7 +41,7 @@ const backgroundColor = computed(() => {
});
// eslint-disable-next-line vue/return-in-computed-property
const title = computed(() => {
switch (store.state.connectionState) {
switch (store.connectionState) {
case OBSConnectionState.Disconnected:
return 'Disconnected';
case OBSConnectionState.Connecting:
Expand Down
33 changes: 3 additions & 30 deletions packages/renderer/src/components/Controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

<script lang="ts" setup>
import { Component } from '/@/layout';
import { useStore } from '/@/store/app';
import { useLayoutStore } from '/@/store/layout';
import { computed } from 'vue';
import ControlComponents from './Controls/Registry';
const store = useStore();
const component = computed(() => store.state.selectedComponent);
const store = useLayoutStore();
const component = computed(() => store.selectedComponent);
const controls = computed(() => {
let controlComponent = Object.getPrototypeOf(component.value);
Expand All @@ -35,31 +35,4 @@ const controls = computed(() => {
} while (controlComponent instanceof Component);
return controlsComponents.reverse();
});
// export default defineComponent({
// name: 'Controls',
// components: {
// ...ControlComponents.components,
// },
// setup() {
// const store = useStore();
// const component = computed(() => store.state.selectedComponent);
// const controls = computed(() => {
// let controlComponent = Object.getPrototypeOf(component.value);
// let controlsComponents = [];
// do {
// let control: any = ControlComponents.registry.get(controlComponent.constructor);
// if (control) {
// controlsComponents.push(control);
// }
// controlComponent = Object.getPrototypeOf(controlComponent);
// } while (controlComponent instanceof Component);
// return controlsComponents.reverse();
// });
// return {
// controls,
// component,
// };
// },
// });
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@

<script lang="ts" setup>
import type { FlexComponent } from '/@/layout';
import { useStore } from '/@/store/app';
import { FLEX_SET_DIRECTION, FLEX_SET_DISTRIBUTION, FLEX_SET_SPACING } from '/@/store/mutation-types';
import { setDirection, setDistribution, setSpacing } from '/@/store/components/flex';
import { useIsWindows } from '/@/integration/platform';
import { computed } from 'vue';
Expand All @@ -48,19 +47,18 @@ const props = defineProps<{
component: FlexComponent
}>();
const store = useStore();
const isWindows = useIsWindows();
const direction = computed({
get(): 'horizontal' | 'vertical' { return props.component.direction; },
set(direction: 'horizontal' | 'vertical') { store.commit(FLEX_SET_DIRECTION, direction); },
set(direction: 'horizontal' | 'vertical') { setDirection(direction); },
});
const distribution = computed({
get(): 'leading' | 'center' | 'trailing' { return props.component.distribution; },
set(distribution: 'leading' | 'center' | 'trailing') { store.commit(FLEX_SET_DISTRIBUTION, distribution); },
set(distribution: 'leading' | 'center' | 'trailing') { setDistribution(distribution); },
});
const spacing = computed({
get() { return props.component.spacing; },
set(spacing: number) { store.commit(FLEX_SET_SPACING, spacing); },
set(spacing: number) { setSpacing(spacing); },
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

<script lang="ts" setup>
import type InsetComponent from '/@/layout/InsetComponent';
import { useStore } from '/@/store/app';
import { INSET_SET_INSETS } from '/@/store/mutation-types';
import { setInsets } from '/@/store/components/inset';
import { computed } from 'vue';
import FormNumberInput from '/@/components/Form/FormNumberInput.vue';
import Controls from './Controls.vue';
Expand All @@ -32,14 +31,12 @@ const props = defineProps<{
component: InsetComponent
}>();
const store = useStore();
const top = computed({
get() { return props.component.insets.top; },
set(newValue: number) {
const insets = props.component.insets;
insets.top = newValue;
store.commit(INSET_SET_INSETS, insets);
setInsets(insets);
},
});
Expand All @@ -48,7 +45,7 @@ const left = computed({
set(newValue: number) {
const insets = props.component.insets;
insets.left = newValue;
store.commit(INSET_SET_INSETS, insets);
setInsets(insets);
},
});
Expand All @@ -57,7 +54,7 @@ const bottom = computed({
set(newValue: number) {
const insets = props.component.insets;
insets.bottom = newValue;
store.commit(INSET_SET_INSETS, insets);
setInsets(insets);
},
});
Expand All @@ -66,7 +63,7 @@ const right = computed({
set(newValue: number) {
const insets = props.component.insets;
insets.right = newValue;
store.commit(INSET_SET_INSETS, insets);
setInsets(insets);
},
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

<script lang="ts" setup>
import type SourceComponent from '/@/layout/SourceComponent';
import { useStore } from '/@/store/app';
import { SOURCE_SET_SOURCE } from '/@/store/mutation-types';
import { setSource } from '/@/store/components/source';
import { useObsStore } from '/@/store/obs';
import { computed } from 'vue';
import FormSelect from '/@/components/Form/FormSelect.vue';
import Controls from './Controls.vue';
Expand All @@ -26,15 +26,15 @@ const props = defineProps<{
component: SourceComponent
}>();
const store = useStore();
const sources = computed(() => store.state.sources);
const obsStore = useObsStore();
const sources = computed(() => obsStore.sources);
const source = computed({
get(): string { return props.component.source?.name ?? ''; },
set(value: string) {
const source = sources.value.find(source => source.name == value);
if (!source) { return; }
store.commit(SOURCE_SET_SOURCE, source);
setSource(source);
},
});
</script>
6 changes: 3 additions & 3 deletions packages/renderer/src/components/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
</template>

<script lang="ts" setup>
import { useStore } from '/@/store/app';
import { useLayoutStore } from '/@/store/layout';
import { computed, ref, watch } from 'vue';
import type { LayoutNode, Size } from '/@/layout';
import { ContainerLayoutNode } from '/@/layout';
import { usePreferredDark } from '@vueuse/core';
const store = useStore();
const store = useLayoutStore();
const scale = ref(1);
const canvas = ref<HTMLCanvasElement | null>(null);
const node = computed(() => store.state.rootNode);
const node = computed(() => store.rootNode);
const prefersDarkMode = usePreferredDark();
const didChangeSize = (newSize: Size) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/renderer/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
</template>

<script lang="ts" setup>
import { useStore } from '/@/store/app';
import { useLayoutStore } from '/@/store/layout';
import { computed } from 'vue';
import TreeControl from './Sidebar/TreeControl.vue';
const store = useStore();
const component = computed(() => store.state.rootComponent);
const store = useLayoutStore();
const component = computed(() => store.rootComponent);
</script>
Loading

0 comments on commit d3a02c7

Please sign in to comment.