Skip to content

Commit

Permalink
Refactored Theme.tsx, Notifications.tsx. Added setting to toggle menu…
Browse files Browse the repository at this point in the history
… bar.
  • Loading branch information
ransome1 committed Mar 31, 2024
1 parent f2718ed commit 01dd168
Show file tree
Hide file tree
Showing 26 changed files with 55 additions and 39 deletions.
2 changes: 1 addition & 1 deletion flatpak/com.github.ransome1.sleek.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<developer_name>Robin Ahle</developer_name>
<content_rating type="oars-1.1"/>
<releases>
<release version="2.0.13" date="2024-03-28"/>
<release version="2.0.14" date="2024-03-31"/>
</releases>
<url type="homepage">https://github.com/ransome1/sleek</url>
<url type="contact">https://github.com/ransome1/sleek/issues</url>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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\"",
Expand Down Expand Up @@ -147,7 +147,7 @@
"webpack-merge": "^5.9.0"
},
"build": {
"buildVersion": "42",
"buildVersion": "43",
"asar": true,
"asarUnpack": "**\\*.{node,dll}",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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í",
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"settings.weekStart": "सप्ताह का पहला दिन",
"settings.0": "रविवार",
"settings.1": "सोमवार",
"settings.menuBarVisibility": "मेनू बार दिखाएं",
"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 @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/locales/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"settings.weekStart": "週の初日",
"settings.0": "日曜日",
"settings.1": "月曜日",
"settings.menuBarVisibility": "メニューバーを表示する",
"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 @@ -30,6 +30,7 @@
"settings.weekStart": "주의 첫날",
"settings.0": "일요일",
"settings.1": "월요일",
"settings.menuBarVisibility": "메뉴 바 표시",
"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 @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"settings.weekStart": "Первый день недели",
"settings.0": "Воскресенье",
"settings.1": "Понедельник",
"settings.menuBarVisibility": "Показать строку меню",
"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 @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"settings.weekStart": "一周的第一天",
"settings.0": "星期日",
"settings.1": "星期一",
"settings.menuBarVisibility": "显示菜单栏",
"drawer.tabs.attributes": "属性",
"drawer.tabs.filters": "过滤器",
"drawer.tabs.sorting": "排序",
Expand Down
12 changes: 10 additions & 2 deletions src/main/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ const config: Store<Settings> = new Store<Settings>({
}
})
},
'2.0.14': store => {
console.log('Migrating from 2.0.13 → 2.0.14');
store.set('menuBarVisibility', true);
},
}
});

Expand Down Expand Up @@ -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) {
Expand All @@ -170,6 +174,10 @@ config.onDidChange('colorTheme', (colorTheme) => {
}
});

config.onDidChange('menuBarVisibility', (menuBarVisibility) => {
mainWindow.setMenuBarVisibility(menuBarVisibility);
});

config.onDidChange('tray', () => {
try {
createTray();
Expand Down
1 change: 0 additions & 1 deletion src/main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ const createMainWindow = () => {
: process.platform === 'darwin'
? getAssetPath('icons/sleek.icns')
: getAssetPath('icons/512x512.png'),
autoHideMenuBar: true,
webPreferences: {
spellcheck: false,
contextIsolation: true,
Expand Down
7 changes: 2 additions & 5 deletions src/main/modules/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
{
Expand All @@ -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',
Expand All @@ -41,7 +38,7 @@ function createMenu(files: FileObject[]) {
mainWindow!.webContents.send('isSettingsOpen', true);
},
},
...(isMac
...(process.platform === 'darwin'
? [
{ type: 'separator' },
{
Expand Down
16 changes: 6 additions & 10 deletions src/main/modules/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dayjs.extend(isToday);
dayjs.extend(isTomorrow);
dayjs.extend(isBetween);


function sendNotification(title: string, body: string) {
const options = {
title,
Expand All @@ -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';
}
Expand All @@ -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;
Expand All @@ -70,4 +66,4 @@ function handleNotification(due: string | null, body: string, badge: Badge) {
}
}

export { sendNotification, handleNotification }
export { sendNotification, handleNotification }
19 changes: 8 additions & 11 deletions src/main/modules/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 3 additions & 0 deletions src/renderer/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
11 changes: 6 additions & 5 deletions src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ declare global {
useMultilineForBulkTodoCreation: boolean;
useHumanFriendlyDates: boolean;
channel: string;
chokidarOptions: object;
__internal__: { migrations: { version: string }};
}

Expand Down Expand Up @@ -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[],
Expand Down

0 comments on commit 01dd168

Please sign in to comment.