mirror of
https://github.com/DCsunset/taskwarrior-webui.git
synced 2025-08-19 06:53:06 +02:00
feat(frontend): add sync in settings
This commit is contained in:
parent
066c92946f
commit
98b4e8be81
6 changed files with 80 additions and 9 deletions
|
@ -51,13 +51,14 @@ export default defineComponent({
|
|||
setup(_props, context) {
|
||||
context.root.$store.dispatch('fetchTasks');
|
||||
|
||||
let interval: NodeJS.Timeout | null = null;
|
||||
// Auto Refresh
|
||||
let refreshInterval: NodeJS.Timeout | null = null;
|
||||
const setAutoRefresh = () => {
|
||||
if (interval)
|
||||
clearInterval(interval);
|
||||
if (refreshInterval)
|
||||
clearInterval(refreshInterval);
|
||||
const freq = +context.root.$store.state.settings.autoRefresh;
|
||||
if (freq > 0) {
|
||||
interval = setInterval(() => {
|
||||
refreshInterval = setInterval(() => {
|
||||
context.root.$store.dispatch('fetchTasks');
|
||||
}, +context.root.$store.state.settings.autoRefresh * 60000);
|
||||
}
|
||||
|
@ -65,6 +66,21 @@ export default defineComponent({
|
|||
setAutoRefresh();
|
||||
watch(() => context.root.$store.state.settings, setAutoRefresh);
|
||||
|
||||
// Auto Sync
|
||||
let syncInterval: NodeJS.Timeout | null = null;
|
||||
const setAutoSync = () => {
|
||||
if (syncInterval)
|
||||
clearInterval(syncInterval);
|
||||
const freq = +context.root.$store.state.settings.autoSync;
|
||||
if (freq > 0) {
|
||||
syncInterval = setInterval(() => {
|
||||
context.root.$store.dispatch('syncTasks');
|
||||
}, +context.root.$store.state.settings.autoSync * 60000);
|
||||
}
|
||||
};
|
||||
setAutoSync();
|
||||
watch(() => context.root.$store.state.settings, setAutoSync);
|
||||
|
||||
const mode = ref('Tasks');
|
||||
const allModes = ['Tasks', 'Projects'];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue