Skip to content

Commit

Permalink
Added missing theme setting, refactored settings, refactored creation…
Browse files Browse the repository at this point in the history
… of todoObject
  • Loading branch information
ransome1 committed Dec 26, 2023
1 parent c40dd9e commit d478cea
Show file tree
Hide file tree
Showing 67 changed files with 818 additions and 831 deletions.
28 changes: 14 additions & 14 deletions src/__tests__/__mock__/recurrence.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

2023-12-24 Line 1 rec:1d due:2023-12-25
2023-12-24 Line 1 rec:w due:2023-12-31
2023-12-24 Line 1 rec:2m due:2024-02-24
2023-12-24 Line 1 rec:+1d due:2023-12-26
2023-12-24 Line 1 rec:7w due:2024-02-11
2023-12-24 Line 1 due:2023-07-24 rec:+1b
2023-12-24 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y
2023-12-24 Water plants @home +quick due:2023-12-31 t:2023-12-21 rec:1w
2023-12-24 Line 1 rec:+1d t:2023-09-20
2023-12-24 Line 1 rec:1d pri:A due:2023-12-25
2023-12-24 (A) Do something rec:d t:2023-12-25 @SomeContext
2023-12-24 Do something rec:0d
2023-12-24 Do something rec:0d due:2023-12-24
2023-12-24 Do something rec:0d due:2023-12-24 t:2023-12-24
2023-12-26 Line 1 rec:1d due:2023-12-27
2023-12-26 Line 1 rec:w due:2024-01-02
2023-12-26 Line 1 rec:2m due:2024-02-26
2023-12-26 Line 1 rec:+1d due:2023-12-28
2023-12-26 Line 1 rec:7w due:2024-02-13
2023-12-26 Line 1 due:2023-07-24 rec:+1b
2023-12-26 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y
2023-12-26 Water plants @home +quick due:2024-01-02 t:2023-12-23 rec:1w
2023-12-26 Line 1 rec:+1d t:2023-09-20
2023-12-26 Line 1 rec:1d pri:A due:2023-12-27
2023-12-26 (A) Do something rec:d t:2023-12-27 @SomeContext
2023-12-26 Do something rec:0d
2023-12-26 Do something rec:0d due:2023-12-26
2023-12-26 Do something rec:0d due:2023-12-26 t:2023-12-26
2 changes: 1 addition & 1 deletion src/__tests__/main/Active.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getActiveFile } from '../../main/Modules/File/Active';
import { getActiveFile } from '../../main/modules/File/Active';

jest.mock('../../main/config', () => ({
configStorage: {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/main/Archive.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import archiveTodos from '../../main/Modules/File/Archive';
import archiveTodos from '../../main/modules/File/Archive';
import fs from 'fs/promises';

jest.mock('electron', () => ({
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/main/Attributes.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { attributes, updateAttributes } from '../../main/Modules/Attributes';
import { attributes, updateAttributes } from '../../main/modules/Attributes';

const todoObjects = [
{ id: 1, created: null, priority: 'A', projects: ['Project 1'], contexts: ['Context 1'], due: '2023-01-01', dueString: '2023-01-01', complete: false, completed: null, t: '2024-02-01', tString: '2024-02-01', rec: null, pm: null, body: null, hidden: false, string: '', notify: false, },
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/main/ChangeCompleteState.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { changeCompleteState } from '../../main/Modules/ProcessDataRequest/ChangeCompleteState';
import { changeCompleteState } from '../../main/modules/ProcessDataRequest/ChangeCompleteState';
import { Item } from 'jstodotxt';
import dayjs from 'dayjs';

const date: string = dayjs(new Date()).format('YYYY-MM-DD');

jest.mock('../../main/Modules/ProcessDataRequest/CreateRecurringTodo', () => ({
jest.mock('../../main/modules/ProcessDataRequest/CreateRecurringTodo', () => ({
createRecurringTodo: jest.fn(),
}));

Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/main/CreateRecurringTodo.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import fs from 'fs/promises';
import { writeTodoObjectToFile } from '../../main/Modules/File/Write';
import { createRecurringTodo } from '../../main/Modules/ProcessDataRequest/CreateRecurringTodo';
import { getActiveFile } from '../../main/Modules/File/Active';
import { lines } from '../../main/Modules/ProcessDataRequest/CreateTodoObjects';
import { writeTodoObjectToFile } from '../../main/modules/File/Write';
import { createRecurringTodo } from '../../main/modules/ProcessDataRequest/CreateRecurringTodo';
import { getActiveFile } from '../../main/modules/File/Active';
import { lines } from '../../main/modules/ProcessDataRequest/CreateTodoObjects';
import dayjs from 'dayjs';

jest.mock('../../main/Modules/ProcessDataRequest/CreateTodoObjects', () => ({
jest.mock('../../main/modules/ProcessDataRequest/CreateTodoObjects', () => ({
lines: [''],
}));

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/main/CreateTodoObjects.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dayjs from 'dayjs';
import { createTodoObjects } from '../../main/Modules/ProcessDataRequest/CreateTodoObjects';
import { createTodoObjects } from '../../main/modules/ProcessDataRequest/CreateTodoObjects';
import { configStorage } from '../../main/config';

const dateTodayString: string = dayjs(new Date()).format('YYYY-MM-DD');
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/main/Date.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { extractSpeakingDates, replaceSpeakingDatesWithAbsoluteDates } from '../../main/Modules/Date';
import { extractSpeakingDates, replaceSpeakingDatesWithAbsoluteDates } from '../../main/modules/Date';
import dayjs from 'dayjs';

jest.mock('../../main/Modules/File/Write', () => ({
jest.mock('../../main/modules/File/Write', () => ({
writeTodoObjectToFile: jest.fn(),
}));

Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/main/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dialog } from 'electron';
import { openFile, createFile } from '../../main/Modules/File/Dialog';
import { addFile } from '../../main/Modules/File/File';
import { openFile, createFile } from '../../main/modules/File/Dialog';
import { addFile } from '../../main/modules/File/File';
import { configStorage } from '../../main/config';
import fs from 'fs/promises';

Expand Down Expand Up @@ -33,7 +33,7 @@ jest.mock('../../main/config', () => ({
},
}));

jest.mock('../../main/Modules/File/File', () => ({
jest.mock('../../main/modules/File/File', () => ({
addFile: jest.fn(),
}));

Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/main/File.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path'
import { configStorage } from '../../main/config';
import { createMenu } from '../../main/Modules/Menu';
import { addFile, removeFile, setFile } from '../../main/Modules/File/File';
import { createMenu } from '../../main/modules/Menu';
import { addFile, removeFile, setFile } from '../../main/modules/File/File';

jest.mock('../../main/main', () => ({
mainWindow: {
Expand All @@ -11,15 +11,15 @@ jest.mock('../../main/main', () => ({
},
}));

jest.mock('../../main/Modules/File/Watcher', () => ({
jest.mock('../../main/modules/File/Watcher', () => ({
createFileWatcher: jest.fn(),
}));

jest.mock('../../main/Modules/Tray', () => ({
jest.mock('../../main/modules/Tray', () => ({
createTray: jest.fn(),
}));

jest.mock('../../main/Modules/Menu', () => ({
jest.mock('../../main/modules/Menu', () => ({
createMenu: jest.fn(),
}));

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/main/Filters.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { applyFilters } from '../../main/Modules/Filters/Filters';
import { applyFilters } from '../../main/modules/Filters/Filters';

describe('Should filter todos based on passed filters', () => {
const todoObjects = [
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/main/Notifications.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { handleNotification } from '../../main/Modules/Notifications';
import { handleNotification } from '../../main/modules/Notifications';
import { configStorage } from '../../main/config';
import { badge } from '../../main/Modules/ProcessDataRequest/CreateTodoObjects';
import { badge } from '../../main/modules/ProcessDataRequest/CreateTodoObjects';
import { Notification } from 'electron';
import dayjs from 'dayjs';

Expand All @@ -10,7 +10,7 @@ const dateTomorrowString = dateToday.add(1, 'day').format('YYYY-MM-DD');
const dateInSevenDaysString = dateToday.add(7, 'day').format('YYYY-MM-DD');
const dateInTwentyDaysString = dateToday.add(20, 'day').format('YYYY-MM-DD');

jest.mock('../../main/Modules/ProcessDataRequest/CreateTodoObjects', () => ({
jest.mock('../../main/modules/ProcessDataRequest/CreateTodoObjects', () => ({
badge: {
count: 0,
},
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/main/ProcessTodoObjects.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sortAndGroupTodoObjects, flattenTodoObjects, applySearchString, countTodoObjects } from '../../main/Modules/ProcessDataRequest/ProcessTodoObjects';
import { sortAndGroupTodoObjects, flattenTodoObjects, applySearchString, countTodoObjects } from '../../main/modules/ProcessDataRequest/ProcessTodoObjects';

jest.mock('../../main/config', () => ({
configStorage: {
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/main/Write.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs/promises';
import { writeTodoObjectToFile, removeLineFromFile } from '../../main/Modules/File/Write';
import { lines } from '../../main/Modules/ProcessDataRequest/CreateTodoObjects';
import { writeTodoObjectToFile, removeLineFromFile } from '../../main/modules/File/Write';
import { lines } from '../../main/modules/ProcessDataRequest/CreateTodoObjects';
import { configStorage } from '../../main/config';
import dayjs from 'dayjs';

Expand Down Expand Up @@ -29,7 +29,7 @@ jest.mock('../../main/config', () => ({
},
}));

jest.mock('../../main/Modules/ProcessDataRequest/CreateTodoObjects', () => ({
jest.mock('../../main/modules/ProcessDataRequest/CreateTodoObjects', () => ({
lines: ['Line 1', 'Line 2', 'Line 3'],
}));

Expand Down
1 change: 1 addition & 0 deletions src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Hranice oznámení",
"settings.bulkTodoCreation": "Každý řádek v textovém poli vytvoří samostatnou položku úkolu",
"settings.matomo": "Povolit analýzu Matomo",
"settings.zoom": "Přiblížení",
"drawer.tabs.attributes": "Atributy",
"drawer.tabs.filters": "Filtry",
"drawer.tabs.sorting": "Řazení",
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Benachrichtigungsschwelle",
"settings.bulkTodoCreation": "Jede Zeile im Textfeld erstellt eine separate Todo",
"settings.matomo": "Matomo-Analyse erlauben",
"settings.zoom": "Vergrößerung",
"drawer.tabs.attributes": "Attribute",
"drawer.tabs.filters": "Filter",
"drawer.tabs.sorting": "Sortierung",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Notification threshold",
"settings.bulkTodoCreation": "Each row in the text field creates a separate to-do item",
"settings.matomo": "Allow Matomo Analysis",
"settings.zoom": "Zoom",
"drawer.tabs.attributes": "Attributes",
"drawer.tabs.filters": "Filters",
"drawer.tabs.sorting": "Sorting",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Notification threshold",
"settings.bulkTodoCreation": "Each row in the text field creates a separate to-do item",
"settings.matomo": "Allow Matomo Analysis",
"settings.zoom": "Zoom",
"drawer.tabs.attributes": "Attributes",
"drawer.tabs.filters": "Filters",
"drawer.tabs.sorting": "Sorting",
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Umbral de notificación",
"settings.bulkTodoCreation": "Cada línea en el campo de texto crea un elemento de tarea separado",
"settings.matomo": "Permitir análisis de Matomo",
"settings.zoom": "Zoom",
"drawer.tabs.attributes": "Atributos",
"drawer.tabs.filters": "Filtros",
"drawer.tabs.sorting": "Ordenación",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Umbral de notificación",
"settings.bulkTodoCreation": "Chaque ligne dans le champ de texte crée un élément de tâche séparé",
"settings.matomo": "Autoriser l'analyse Matomo",
"settings.zoom": "Zoom",
"drawer.tabs.attributes": "Attributs",
"drawer.tabs.filters": "Filtres",
"drawer.tabs.sorting": "Tri",
Expand Down
1 change: 1 addition & 0 deletions src/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "सूचना सीमा",
"settings.bulkTodoCreation": "पाठ क्षेत्र में प्रत्येक पंक्ति स्वतंत्र टूडू आइटम बनाती है",
"settings.matomo": "मैटोमो विश्लेषण की अनुमति दें",
"settings.zoom": "ज़ूम",
"drawer.tabs.attributes": "गुण",
"drawer.tabs.filters": "फ़िल्टर",
"drawer.tabs.sorting": "क्रमबद्ध करना",
Expand Down
1 change: 1 addition & 0 deletions src/locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Értesítés küszöbérték",
"settings.bulkTodoCreation": "Minden sor külön teendőelemet hoz létre a szövegmezőben",
"settings.matomo": "Matomo elemzés engedélyezése",
"settings.zoom": "Nagyítás",
"drawer.tabs.attributes": "Tulajdonságok",
"drawer.tabs.filters": "Szűrők",
"drawer.tabs.sorting": "Rendezés",
Expand Down
1 change: 1 addition & 0 deletions src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Soglia di notifica",
"settings.bulkTodoCreation": "Ogni riga nel campo di testo crea un'attività separata",
"settings.matomo": "Consenti l'analisi di Matomo",
"settings.zoom": "Zoom",
"drawer.tabs.attributes": "Attributi",
"drawer.tabs.filters": "Filtri",
"drawer.tabs.sorting": "Ordinamento",
Expand Down
1 change: 1 addition & 0 deletions src/locales/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "通知しきい値",
"settings.bulkTodoCreation": "テキストフィールド内の各行は別々のタスクを作成します",
"settings.matomo": "Matomoの分析を許可",
"settings.zoom": "ズーム",
"drawer.tabs.attributes": "属性",
"drawer.tabs.filters": "フィルター",
"drawer.tabs.sorting": "ソート",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "알림 임계값",
"settings.bulkTodoCreation": "텍스트 필드의 각 줄은 별도의 할 일 항목을 생성합니다",
"settings.matomo": "Matomo 분석 허용",
"settings.zoom": "",
"drawer.tabs.attributes": "속성",
"drawer.tabs.filters": "필터",
"drawer.tabs.sorting": "정렬",
Expand Down
1 change: 1 addition & 0 deletions src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Prog powiadomień",
"settings.bulkTodoCreation": "Każdy wiersz w polu tekstowym tworzy oddzielną pozycję na liście zadań",
"settings.matomo": "Zezwalaj na analizę Matomo",
"settings.zoom": "Powiększenie",
"drawer.tabs.attributes": "Atrybuty",
"drawer.tabs.filters": "Filtry",
"drawer.tabs.sorting": "Sortowanie",
Expand Down
1 change: 1 addition & 0 deletions src/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Prog powiadomień",
"settings.bulkTodoCreation": "Cada linha no campo de texto cria um item de tarefa separado",
"settings.matomo": "Permitir Análise do Matomo",
"settings.zoom": "Zoom",
"drawer.tabs.attributes": "Atributos",
"drawer.tabs.filters": "Filtros",
"drawer.tabs.sorting": "Ordenação",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Порог уведомлений",
"settings.bulkTodoCreation": "Каждая строка в текстовом поле создает отдельную задачу",
"settings.matomo": "Разрешить анализ Matomo",
"settings.zoom": "Масштаб",
"drawer.tabs.attributes": "Атрибуты",
"drawer.tabs.filters": "Фильтры",
"drawer.tabs.sorting": "Сортировка",
Expand Down
1 change: 1 addition & 0 deletions src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "Bildirim Eşik Değeri",
"settings.bulkTodoCreation": "Metin alanındaki her satır ayrı bir görev oluşturur",
"settings.matomo": "Matomo Analizine İzin Ver",
"settings.zoom": "Yakınlaştırma",
"drawer.tabs.attributes": "Özellikler",
"drawer.tabs.filters": "Filtreler",
"drawer.tabs.sorting": "Sıralama",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"settings.notificationThreshold": "通知阈值",
"settings.bulkTodoCreation": "文本字段中的每一行都创建一个单独的待办事项",
"settings.matomo": "允许Matomo分析",
"settings.zoom": "缩放",
"drawer.tabs.attributes": "属性",
"drawer.tabs.filters": "过滤器",
"drawer.tabs.sorting": "排序",
Expand Down
26 changes: 9 additions & 17 deletions src/main/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import path from 'path';
import { app, nativeTheme } from 'electron';
import fs from 'fs';
import { mainWindow } from './main';
import { createFileWatcher } from './Modules/File/Watcher';
import { createTray } from './Modules/Tray';
import processDataRequest from './Modules/ProcessDataRequest/ProcessDataRequest';
import handleTheme from './Modules/Theme';
import { createFileWatcher } from './modules/File/Watcher';
import { createTray } from './modules/Tray';
import processDataRequest from './modules/ProcessDataRequest/ProcessDataRequest';
import handleTheme from './modules/Theme';
import crypto from 'crypto';

const anonymousUserId = crypto.randomUUID() || null;
Expand Down Expand Up @@ -105,39 +105,31 @@ if(!fs.existsSync(customStylesPath)) {

filterStorage.onDidAnyChange(async () => {
try {
await processDataRequest()
await processDataRequest();
} catch(error) {
console.error(error);
}
});

configStorage.onDidAnyChange(async () => {
configStorage.onDidAnyChange(async(settings) => {
try {
await processDataRequest()
await processDataRequest();
mainWindow!.webContents.send('settingsChanged', settings);
} catch(error) {
console.error(error);
}
});

configStorage.onDidChange('files', async (files: FileObject[] | undefined) => {
try {
if(files && mainWindow) {
if(files) {
createFileWatcher(files);
mainWindow.webContents.send('updateFiles', files);
}
} catch(error) {
console.error(error);
}
});

configStorage.onDidChange('matomo', (matomo) => {
mainWindow!.webContents.send('matomo', matomo);
});

configStorage.onDidChange('showFileTabs', () => {
mainWindow!.webContents.send('setShowFileTabs');
});

configStorage.onDidChange('colorTheme', (colorTheme) => {
if(colorTheme === 'system' || colorTheme === 'light' || colorTheme === 'dark') {
nativeTheme.themeSource = colorTheme;
Expand Down
10 changes: 5 additions & 5 deletions src/main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { app, BrowserWindow } from 'electron';
import path from 'path';
import fs from 'fs';
import { configStorage } from './config';
import { createMenu } from './Modules/Menu';
import handleTheme from './Modules/Theme';
import { createMenu } from './modules/Menu';
import handleTheme from './modules/Theme';
import { getAssetPath, resolveHtmlPath } from './util';
import { createFileWatcher, watcher } from './Modules/File/Watcher';
import { createTray } from './Modules/Tray';
import './Modules/Ipc';
import { createFileWatcher, watcher } from './modules/File/Watcher';
import { createTray } from './modules/Tray';
import './modules/Ipc';

const environment: string | undefined = process.env.NODE_ENV;
const files: FileObject[] = (configStorage.get('files') as FileObject[]) || [];
Expand Down
Loading

0 comments on commit d478cea

Please sign in to comment.