From 13f8f4d63e1458b18fc60f1e551475d015b402e9 Mon Sep 17 00:00:00 2001 From: ransome1 Date: Wed, 27 Mar 2024 18:14:03 +0100 Subject: [PATCH] Fixed https://github.com/ransome1/sleek/issues/609#issuecomment-2016756390. Introducing chokidarOptions settings (https://github.com/ransome1/sleek/issues/692) and reverting default filewatcher configuration to pre 2.0.12 --- flatpak/com.github.ransome1.sleek.appdata.xml | 2 +- package.json | 2 +- release/app/package.json | 2 +- snap/snapcraft.yaml | 2 +- src/main/config.tsx | 13 +++++++++++-- src/main/modules/File/Watcher.tsx | 12 +++--------- src/renderer/App.tsx | 2 +- src/renderer/Dialog/DatePicker.tsx | 5 +++++ src/renderer/Header/Search/Input.scss | 3 --- src/renderer/Settings/LanguageSelector.tsx | 2 +- src/renderer/Shared.tsx | 5 ++--- src/renderer/index.ejs | 2 +- 12 files changed, 28 insertions(+), 24 deletions(-) diff --git a/flatpak/com.github.ransome1.sleek.appdata.xml b/flatpak/com.github.ransome1.sleek.appdata.xml index 6c7c9faf..564de91a 100755 --- a/flatpak/com.github.ransome1.sleek.appdata.xml +++ b/flatpak/com.github.ransome1.sleek.appdata.xml @@ -9,7 +9,7 @@ Robin Ahle - + https://github.com/ransome1/sleek https://github.com/ransome1/sleek/issues diff --git a/package.json b/package.json index 913a5361..e916d891 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sleek", - "version": "2.0.13-rc.1", + "version": "2.0.13-rc.2", "main": "./src/main/main.tsx", "scripts": { "build": "concurrently \"yarn run peggy\" \"yarn run build:main\" \"yarn run build:renderer\"", diff --git a/release/app/package.json b/release/app/package.json index 068a2e65..60a86252 100644 --- a/release/app/package.json +++ b/release/app/package.json @@ -1,6 +1,6 @@ { "name": "sleek", - "version": "2.0.13-rc.1", + "version": "2.0.13-rc.2", "description": "todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)", "synopsis": "todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)", "keywords": [ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 1364ee44..4c578738 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: sleek base: core20 -version: "2.0.13-rc.1" +version: "2.0.13-rc.2" summary: todo.txt manager for Linux, free and open-source (FOSS) description: | sleek is an open-source (FOSS) todo manager based on the todo.txt syntax. Stripped down to only the most necessary features, and with a clean and simple interface, sleek aims to help you focus on getting things done. diff --git a/src/main/config.tsx b/src/main/config.tsx index 27f793fd..0ba24272 100644 --- a/src/main/config.tsx +++ b/src/main/config.tsx @@ -104,9 +104,18 @@ const config: Store = new Store({ store.set('fileWatcherPolling', false); store.set('fileWatcherPollingInterval', 100); }, - '2.0.13': store => { - console.log('Migrating from 2.0.12 → 2.0.13'); + '2.0.13-rc.2': store => { + console.log('Migrating from 2.0.12 → 2.0.13-rc.2'); store.set('weekStart', 1); + store.delete('fileWatcherAtomic'); + store.delete('fileWatcherPolling'); + store.delete('fileWatcherPollingInterval'); + store.set('chokidarOptions', { + awaitWriteFinish: { + stabilityThreshold: 100, + pollInterval: 100 + } + }) }, } }); diff --git a/src/main/modules/File/Watcher.tsx b/src/main/modules/File/Watcher.tsx index 28ae4b0a..0432b050 100644 --- a/src/main/modules/File/Watcher.tsx +++ b/src/main/modules/File/Watcher.tsx @@ -17,15 +17,9 @@ function createFileWatcher(files: FileObject[]): void { config.set('files', files) } - const fileWatcherAtomic = config.get('fileWatcherAtomic') || 1000; - const fileWatcherPolling = config.get('fileWatcherPolling') || false; - const fileWatcherPollingInterval = config.get('fileWatcherPollingInterval') || 100; - - watcher = chokidar.watch(files.map((file) => file.todoFilePath), { - atomic: fileWatcherAtomic, - usePolling: fileWatcherPolling, - interval: fileWatcherPollingInterval - }); + const chokidarOptions = config.get('chokidarOptions'); + + watcher = chokidar.watch(files.map((file) => file.todoFilePath), chokidarOptions); watcher .on('add', (file) => { diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index bbfda3fd..736fb150 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -64,7 +64,7 @@ const App = () => { .catch((error) => { console.error(error); }); - }, [settings.language]); + }, [settings.language]); useEffect(() => { const windowHeight = window.innerHeight; diff --git a/src/renderer/Dialog/DatePicker.tsx b/src/renderer/Dialog/DatePicker.tsx index ece8845b..d0eadec1 100644 --- a/src/renderer/Dialog/DatePicker.tsx +++ b/src/renderer/Dialog/DatePicker.tsx @@ -4,7 +4,9 @@ import { i18n } from '../Settings/LanguageSelector'; import { DatePicker, LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import dayjs from 'dayjs'; +import updateLocale from 'dayjs/plugin/updateLocale'; import './DatePicker.scss'; +dayjs.extend(updateLocale); interface Props extends WithTranslation { date: string | null; @@ -21,6 +23,9 @@ const DatePickerComponent: React.FC = ({ handleChange, t, }) => { + dayjs.updateLocale(settings.language, { + weekStart: settings.weekStart, + }); return ( { if(!store.getConfig('language')) { - store.setConfig('language', navigator.language.toLowerCase()); + store.setConfig('language', navigator.language.toLowerCase().substr(0, 2)); } i18n.on('missingKey', (key: string) => { console.warn(`Missing translation key: ${key}`); diff --git a/src/renderer/Shared.tsx b/src/renderer/Shared.tsx index 738f8376..cb04f058 100644 --- a/src/renderer/Shared.tsx +++ b/src/renderer/Shared.tsx @@ -75,7 +75,7 @@ export const friendlyDate = (value: string, attributeKey: string, settings: Sett results.push((attributeKey === 'due') ? t('drawer.attributes.overdue') : t('drawer.attributes.elapsed')); } - if (date.isAfter(today.subtract(1, 'week').startOf('week')) && date.isBefore(today.subtract(1, 'week').endOf('week'))) { + if (date.isAfter(today.subtract(1, 'week').startOf('week').subtract(1, 'day')) && date.isBefore(today.subtract(1, 'week').endOf('week'))) { results.push(t('drawer.attributes.lastWeek')); } @@ -99,13 +99,12 @@ export const friendlyDate = (value: string, attributeKey: string, settings: Sett results.push(t('drawer.attributes.tomorrow')); } - if (date.isSame(today.add(1, 'week'), 'week')) { results.push(t('drawer.attributes.nextWeek')); } if (date.month() === today.add(1, 'month').month()) { - results.push(t('drawer.attributes.nextMonth')); + results.push(t('drawer.attributes.nextMonth')); } if (date.isAfter(today.add(2, 'month').startOf('month'))) { diff --git a/src/renderer/index.ejs b/src/renderer/index.ejs index ef569c5d..2f109a65 100644 --- a/src/renderer/index.ejs +++ b/src/renderer/index.ejs @@ -4,7 +4,7 @@ sleek