compositionApi: ReloadControl

This commit is contained in:
Matthias 2022-04-15 20:09:28 +02:00
parent 33660e65c1
commit ce85a70bc6

View File

@ -18,35 +18,40 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { namespace } from 'vuex-class';
import RefreshIcon from 'vue-material-design-icons/Refresh.vue'; import RefreshIcon from 'vue-material-design-icons/Refresh.vue';
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper'; import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
import StoreModules from '@/store/storeSubModules'; import StoreModules from '@/store/storeSubModules';
import { defineComponent, computed } from '@vue/composition-api';
import { useNamespacedActions, useNamespacedGetters } from 'vuex-composition-helpers';
const ftbot = namespace(StoreModules.ftbot); export default defineComponent({
name: 'ReloadControl',
components: { RefreshIcon },
setup() {
const { globalAutoRefresh } = useNamespacedGetters(StoreModules.ftbot, [
MultiBotStoreGetters.globalAutoRefresh,
]);
const { setGlobalAutoRefresh, allRefreshFull } = useNamespacedActions(StoreModules.ftbot, [
'setGlobalAutoRefresh',
'allRefreshFull',
]);
const autoRefreshLoc = computed({
get() {
return globalAutoRefresh.value;
},
set(newValue: boolean) {
setGlobalAutoRefresh(newValue);
},
});
@Component({ components: { RefreshIcon } }) return {
export default class ReloadControl extends Vue { globalAutoRefresh,
refreshInterval: number | null = null; setGlobalAutoRefresh,
allRefreshFull,
refreshIntervalSlow: number | null = null; autoRefreshLoc,
};
@ftbot.Getter [MultiBotStoreGetters.globalAutoRefresh]!: boolean; },
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ftbot.Action setGlobalAutoRefresh!: (newValue: boolean) => void;
@ftbot.Action allRefreshFull;
get autoRefreshLoc() {
return this.globalAutoRefresh;
}
set autoRefreshLoc(newValue: boolean) {
this.setGlobalAutoRefresh(newValue);
}
}
</script> </script>
<style scoped></style> <style scoped></style>