From 01dd16807c0407e0b5b80e2c783d3a8ce5b55b9d Mon Sep 17 00:00:00 2001 From: ransome1 Date: Sun, 31 Mar 2024 10:27:07 +0200 Subject: [PATCH] Refactored Theme.tsx, Notifications.tsx. Added setting to toggle menu bar. --- flatpak/com.github.ransome1.sleek.appdata.xml | 2 +- package.json | 4 ++-- release/app/package.json | 2 +- snap/snapcraft.yaml | 2 +- src/locales/cs.json | 1 + src/locales/de.json | 1 + src/locales/en.json | 1 + src/locales/es.json | 1 + src/locales/fr.json | 1 + src/locales/hi.json | 1 + src/locales/hu.json | 1 + src/locales/it.json | 1 + src/locales/jp.json | 1 + src/locales/ko.json | 1 + src/locales/pl.json | 1 + src/locales/pt.json | 1 + src/locales/ru.json | 1 + src/locales/tr.json | 1 + src/locales/zh.json | 1 + src/main/config.tsx | 12 ++++++++++-- src/main/main.tsx | 1 - src/main/modules/Menu.tsx | 7 ++----- src/main/modules/Notifications.tsx | 16 ++++++---------- src/main/modules/Theme.tsx | 19 ++++++++----------- src/renderer/Settings/Settings.tsx | 3 +++ src/types.tsx | 11 ++++++----- 26 files changed, 55 insertions(+), 39 deletions(-) diff --git a/flatpak/com.github.ransome1.sleek.appdata.xml b/flatpak/com.github.ransome1.sleek.appdata.xml index f2084765..85ea823c 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 b4f02118..f1f7428a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sleek", - "version": "2.0.13", + "version": "2.0.14", "main": "./src/main/main.tsx", "scripts": { "build": "concurrently \"yarn run peggy\" \"yarn run build:main\" \"yarn run build:renderer\"", @@ -147,7 +147,7 @@ "webpack-merge": "^5.9.0" }, "build": { - "buildVersion": "42", + "buildVersion": "43", "asar": true, "asarUnpack": "**\\*.{node,dll}", "files": [ diff --git a/release/app/package.json b/release/app/package.json index 5f0f696c..23a95e98 100644 --- a/release/app/package.json +++ b/release/app/package.json @@ -1,6 +1,6 @@ { "name": "sleek", - "version": "2.0.13", + "version": "2.0.14", "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 1fd348a9..0a887e8c 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: sleek base: core20 -version: "2.0.13" +version: "2.0.14" 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/locales/cs.json b/src/locales/cs.json index 7139db87..55dfbe55 100644 --- a/src/locales/cs.json +++ b/src/locales/cs.json @@ -30,6 +30,7 @@ "settings.weekStart": "První den týdne", "settings.0": "Neděle", "settings.1": "Pondělí", + "settings.menuBarVisibility": "Zobrazit menu v panelu", "drawer.tabs.attributes": "Atributy", "drawer.tabs.filters": "Filtry", "drawer.tabs.sorting": "Řazení", diff --git a/src/locales/de.json b/src/locales/de.json index 670b85d9..f2ac1210 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -30,6 +30,7 @@ "settings.weekStart": "Erster Tag der Woche", "settings.0": "Sonntag", "settings.1": "Montag", + "settings.menuBarVisibility": "Menüleiste anzeigen", "drawer.tabs.attributes": "Attribute", "drawer.tabs.filters": "Filter", "drawer.tabs.sorting": "Sortierung", diff --git a/src/locales/en.json b/src/locales/en.json index 2bee9676..5ca3b75c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -30,6 +30,7 @@ "settings.weekStart": "First day of the week", "settings.0": "Sunday", "settings.1": "Monday", + "settings.menuBarVisibility": "Show menu bar", "drawer.tabs.attributes": "Attributes", "drawer.tabs.filters": "Filters", "drawer.tabs.sorting": "Sorting", diff --git a/src/locales/es.json b/src/locales/es.json index 996044d0..0ebaa809 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -30,6 +30,7 @@ "settings.weekStart": "Primer día de la semana", "settings.0": "Domingo", "settings.1": "Lunes", + "settings.menuBarVisibility": "Mostrar barra de menú", "drawer.tabs.attributes": "Atributos", "drawer.tabs.filters": "Filtros", "drawer.tabs.sorting": "Ordenación", diff --git a/src/locales/fr.json b/src/locales/fr.json index 7793d33e..93fdf489 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -30,6 +30,7 @@ "settings.weekStart": "Premier jour de la semaine", "settings.0": "Dimanche", "settings.1": "Lundi", + "settings.menuBarVisibility": "Afficher la barre de menus", "drawer.tabs.attributes": "Attributs", "drawer.tabs.filters": "Filtres", "drawer.tabs.sorting": "Tri", diff --git a/src/locales/hi.json b/src/locales/hi.json index db1407d9..2e0a334d 100644 --- a/src/locales/hi.json +++ b/src/locales/hi.json @@ -30,6 +30,7 @@ "settings.weekStart": "सप्ताह का पहला दिन", "settings.0": "रविवार", "settings.1": "सोमवार", + "settings.menuBarVisibility": "मेनू बार दिखाएं", "drawer.tabs.attributes": "गुण", "drawer.tabs.filters": "फ़िल्टर", "drawer.tabs.sorting": "क्रमबद्ध करना", diff --git a/src/locales/hu.json b/src/locales/hu.json index 01f08da2..d5a556b5 100644 --- a/src/locales/hu.json +++ b/src/locales/hu.json @@ -30,6 +30,7 @@ "settings.weekStart": "Hét első napja", "settings.0": "Vasárnap", "settings.1": "Hétfő", + "settings.menuBarVisibility": "Menüsor megjelenítése", "drawer.tabs.attributes": "Tulajdonságok", "drawer.tabs.filters": "Szűrők", "drawer.tabs.sorting": "Rendezés", diff --git a/src/locales/it.json b/src/locales/it.json index 75cb78fd..efb16439 100644 --- a/src/locales/it.json +++ b/src/locales/it.json @@ -30,6 +30,7 @@ "settings.weekStart": "Primo giorno della settimana", "settings.0": "Domenica", "settings.1": "Lunedì", + "settings.menuBarVisibility": "Mostra la barra dei menu", "drawer.tabs.attributes": "Attributi", "drawer.tabs.filters": "Filtri", "drawer.tabs.sorting": "Ordinamento", diff --git a/src/locales/jp.json b/src/locales/jp.json index 164dca75..33184b9a 100644 --- a/src/locales/jp.json +++ b/src/locales/jp.json @@ -30,6 +30,7 @@ "settings.weekStart": "週の初日", "settings.0": "日曜日", "settings.1": "月曜日", + "settings.menuBarVisibility": "メニューバーを表示する", "drawer.tabs.attributes": "属性", "drawer.tabs.filters": "フィルター", "drawer.tabs.sorting": "ソート", diff --git a/src/locales/ko.json b/src/locales/ko.json index 45fa5249..4d19a7ce 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -30,6 +30,7 @@ "settings.weekStart": "주의 첫날", "settings.0": "일요일", "settings.1": "월요일", + "settings.menuBarVisibility": "메뉴 바 표시", "drawer.tabs.attributes": "속성", "drawer.tabs.filters": "필터", "drawer.tabs.sorting": "정렬", diff --git a/src/locales/pl.json b/src/locales/pl.json index 13973472..de560caa 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -30,6 +30,7 @@ "settings.weekStart": "Pierwszy dzień tygodnia", "settings.0": "Niedziela", "settings.1": "Poniedziałek", + "settings.menuBarVisibility": "Pokaż pasek menu", "drawer.tabs.attributes": "Atrybuty", "drawer.tabs.filters": "Filtry", "drawer.tabs.sorting": "Sortowanie", diff --git a/src/locales/pt.json b/src/locales/pt.json index f2933dbc..32982fa2 100644 --- a/src/locales/pt.json +++ b/src/locales/pt.json @@ -30,6 +30,7 @@ "settings.weekStart": "Primeiro dia da semana", "settings.0": "Domingo", "settings.1": "Segunda-feira", + "settings.menuBarVisibility": "Mostrar barra de menu", "drawer.tabs.attributes": "Atributos", "drawer.tabs.filters": "Filtros", "drawer.tabs.sorting": "Ordenação", diff --git a/src/locales/ru.json b/src/locales/ru.json index 6b01c0b5..b643ce97 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -30,6 +30,7 @@ "settings.weekStart": "Первый день недели", "settings.0": "Воскресенье", "settings.1": "Понедельник", + "settings.menuBarVisibility": "Показать строку меню", "drawer.tabs.attributes": "Атрибуты", "drawer.tabs.filters": "Фильтры", "drawer.tabs.sorting": "Сортировка", diff --git a/src/locales/tr.json b/src/locales/tr.json index 5b0add70..86f766cb 100644 --- a/src/locales/tr.json +++ b/src/locales/tr.json @@ -30,6 +30,7 @@ "settings.weekStart": "Haftanın ilk günü", "settings.0": "Pazar", "settings.1": "Pazartesi", + "settings.menuBarVisibility": "Menü çubuğunu göster", "drawer.tabs.attributes": "Özellikler", "drawer.tabs.filters": "Filtreler", "drawer.tabs.sorting": "Sıralama", diff --git a/src/locales/zh.json b/src/locales/zh.json index e0e9af34..894ab358 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -30,6 +30,7 @@ "settings.weekStart": "一周的第一天", "settings.0": "星期日", "settings.1": "星期一", + "settings.menuBarVisibility": "显示菜单栏", "drawer.tabs.attributes": "属性", "drawer.tabs.filters": "过滤器", "drawer.tabs.sorting": "排序", diff --git a/src/main/config.tsx b/src/main/config.tsx index 5f5d1297..e63a22bd 100644 --- a/src/main/config.tsx +++ b/src/main/config.tsx @@ -118,6 +118,10 @@ const config: Store = new Store({ } }) }, + '2.0.14': store => { + console.log('Migrating from 2.0.13 → 2.0.14'); + store.set('menuBarVisibility', true); + }, } }); @@ -154,9 +158,9 @@ config.onDidAnyChange(async(settings) => { } }); -config.onDidChange('files', (newValue: FileObject[] | null) => { +config.onDidChange('files', (newValue: FileObject[] | undefined) => { try { - if (newValue) { + if (newValue !== undefined) { createFileWatcher(newValue); } } catch (error: any) { @@ -170,6 +174,10 @@ config.onDidChange('colorTheme', (colorTheme) => { } }); +config.onDidChange('menuBarVisibility', (menuBarVisibility) => { + mainWindow.setMenuBarVisibility(menuBarVisibility); +}); + config.onDidChange('tray', () => { try { createTray(); diff --git a/src/main/main.tsx b/src/main/main.tsx index ee4384ae..6d1723ae 100644 --- a/src/main/main.tsx +++ b/src/main/main.tsx @@ -110,7 +110,6 @@ const createMainWindow = () => { : process.platform === 'darwin' ? getAssetPath('icons/sleek.icns') : getAssetPath('icons/512x512.png'), - autoHideMenuBar: true, webPreferences: { spellcheck: false, contextIsolation: true, diff --git a/src/main/modules/Menu.tsx b/src/main/modules/Menu.tsx index 836c48f7..efc12740 100644 --- a/src/main/modules/Menu.tsx +++ b/src/main/modules/Menu.tsx @@ -6,9 +6,6 @@ import { handleRequestArchive } from './File/Archive'; import { config, filter } from '../config'; import appPackage from '../../../release/app/package.json'; -const isMac: boolean = process.platform === 'darwin'; -const description = appPackage.description; - function createMenu(files: FileObject[]) { const template: Electron.MenuItemConstructorOptions[] = [ { @@ -21,7 +18,7 @@ function createMenu(files: FileObject[]) { const options = { title: 'About sleek', message: `sleek v${app.getVersion()}`, - detail: description, + detail: appPackage.description, buttons: [ 'Close', 'Reveal configuration folder', @@ -41,7 +38,7 @@ function createMenu(files: FileObject[]) { mainWindow!.webContents.send('isSettingsOpen', true); }, }, - ...(isMac + ...(process.platform === 'darwin' ? [ { type: 'separator' }, { diff --git a/src/main/modules/Notifications.tsx b/src/main/modules/Notifications.tsx index f09fa276..5fd11c12 100644 --- a/src/main/modules/Notifications.tsx +++ b/src/main/modules/Notifications.tsx @@ -10,7 +10,6 @@ dayjs.extend(isToday); dayjs.extend(isTomorrow); dayjs.extend(isBetween); - function sendNotification(title: string, body: string) { const options = { title, @@ -24,8 +23,8 @@ function sendNotification(title: string, body: string) { function createSpeakingDifference(dueDate: Dayjs) { const today = dayjs(); const daysUntilDue: number = dueDate.diff(today, 'day') + 1; - if(dayjs(dueDate).isToday()) return 'Due today'; - if(dayjs(dueDate).isTomorrow()) return 'Due tomorrow'; + if(dueDate.isToday()) return 'Due today'; + if(dueDate.isTomorrow()) return 'Due tomorrow'; if(daysUntilDue > 1) return `Due in ${daysUntilDue} days`; return 'Due'; } @@ -44,15 +43,12 @@ function isNotificationSuppressed(searchFilters: SearchFilter[], body: string) { return suppressNotification; } -function handleNotification(due: string | null, body: string, badge: Badge) { - const notificationAllowed = config.get('notificationsAllowed'); - - if(notificationAllowed) { +function handleNotification(due: string | null, body: string, badge: Badge) { + if(config.get('notificationsAllowed')) { const today = dayjs().startOf('day'); - const todayString = today.format('YYYY-MM-DD'); const dueDate = dayjs(due, 'YYYY-MM-DD'); const notificationThreshold: number = config.get('notificationThreshold'); - const hash = todayString + crypto.createHash('sha256').update(body).digest('hex'); + const hash = today.format('YYYY-MM-DD') + crypto.createHash('sha256').update(body).digest('hex'); const searchFilters: SearchFilter[] = filter.get('search') || []; if(isNotificationSuppressed(searchFilters, body)) return; @@ -70,4 +66,4 @@ function handleNotification(due: string | null, body: string, badge: Badge) { } } -export { sendNotification, handleNotification } +export { sendNotification, handleNotification } \ No newline at end of file diff --git a/src/main/modules/Theme.tsx b/src/main/modules/Theme.tsx index 1484924c..cbbd84cf 100644 --- a/src/main/modules/Theme.tsx +++ b/src/main/modules/Theme.tsx @@ -2,18 +2,15 @@ import { nativeTheme } from 'electron'; import { config } from '../config'; function handleTheme() { - const colorTheme: string = config.get('colorTheme'); - let shouldUseDarkColors: boolean; - if(colorTheme === 'system') { - shouldUseDarkColors = nativeTheme.shouldUseDarkColors; - } else if(colorTheme === 'dark') { - shouldUseDarkColors = true; - } else if(colorTheme === 'light') { - shouldUseDarkColors = false; + if(nativeTheme.themeSource === 'system') { + config.set('shouldUseDarkColors', nativeTheme.shouldUseDarkColors); + } else if(nativeTheme.themeSource === 'dark') { + config.set('shouldUseDarkColors', true); + } else if(nativeTheme.themeSource === 'light') { + config.set('shouldUseDarkColors', false); } else { - shouldUseDarkColors = false; + config.set('shouldUseDarkColors', false); } - config.set('shouldUseDarkColors', shouldUseDarkColors); } -export default handleTheme; +export default handleTheme; \ No newline at end of file diff --git a/src/renderer/Settings/Settings.tsx b/src/renderer/Settings/Settings.tsx index 9987b1f5..896800e8 100644 --- a/src/renderer/Settings/Settings.tsx +++ b/src/renderer/Settings/Settings.tsx @@ -27,6 +27,9 @@ const visibleSettings: VisibleSettings = { tray: { style: 'toggle', }, + menuBarVisibility: { + style: 'toggle', + }, bulkTodoCreation: { style: 'toggle', help: 'https://github.com/ransome1/sleek/wiki/Multi%E2%80%90line-text-field#bulk-todo-creation', diff --git a/src/types.tsx b/src/types.tsx index 5197fba7..6f02ef73 100644 --- a/src/types.tsx +++ b/src/types.tsx @@ -82,6 +82,7 @@ declare global { useMultilineForBulkTodoCreation: boolean; useHumanFriendlyDates: boolean; channel: string; + chokidarOptions: object; __internal__: { migrations: { version: string }}; } @@ -190,11 +191,11 @@ declare global { count: number; }; - type ElementObject = { - type: string | null; - value: string | null; - index: number; - }; + // type ElementObject = { + // type: string | null; + // value: string | null; + // index: number; + // }; interface RequestedData { todoObjects: TodoObject[],