Skip to content

Commit

Permalink
Further worked out the search filter function. Added keyboard shortcu…
Browse files Browse the repository at this point in the history
…t to open search filter container. Added function to suppress notifications of todos, that match a given search filter
  • Loading branch information
ransome1 committed Jan 15, 2024
1 parent adc4429 commit 14174aa
Show file tree
Hide file tree
Showing 25 changed files with 196 additions and 145 deletions.
Binary file removed assets/fonts/FreeSans.otf
Binary file not shown.
Binary file removed assets/fonts/FreeSans.ttf
Binary file not shown.
Binary file removed assets/fonts/FreeSansBold.otf
Binary file not shown.
Binary file removed assets/fonts/FreeSansBold.ttf
Binary file not shown.
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.7-rc.3" date="2024-01-14"/>
<release version="2.0.7-rc.4" date="2024-01-15"/>
</releases>
<url type="homepage">https://github.com/ransome1/sleek</url>
<url type="contact">https://github.com/ransome1/sleek/issues</url>
Expand Down
2 changes: 1 addition & 1 deletion flatpak/com.github.ransome1.sleek.desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Desktop Entry]
Version=2.0.7-rc.3
Version=2.0.7-rc.4
Name=sleek
Exec=sleek
Type=Application
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sleek",
"version": "2.0.7-rc.3",
"version": "2.0.7-rc.4",
"main": "./src/main/main.tsx",
"scripts": {
"build": "concurrently \"yarn run peggy\" \"yarn run build:main\" \"yarn run build:renderer\"",
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.7-rc.3",
"version": "2.0.7-rc.4",
"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.7-rc.3"
version: "2.0.7-rc.4"
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
14 changes: 7 additions & 7 deletions src/main/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ filter.onDidChange('attributes', async () => {
}
});

filter.onDidChange('search', async () => {
try {
await processDataRequest(searchString);
} catch(error: any) {
console.error(error);
}
});
// filter.onDidChange('search', async () => {
// try {
// await processDataRequest(searchString);
// } catch(error: any) {
// console.error(error);
// }
// });

config.onDidAnyChange(async(settings) => {
try {
Expand Down
51 changes: 24 additions & 27 deletions src/main/modules/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ function createSpeakingDifference(dueDate: Dayjs) {
return 'Due';
}

function isNotificationSuppressed(searchFilters, body) {
let suppressNotification = false;
for (const searchFilter of searchFilters) {
if (searchFilter.label && searchFilter.suppress) {
const match = checkForSearchMatches(body, searchFilter.label);
if (match) {
suppressNotification = true;
break;
}
}
}
return suppressNotification;
}

function handleNotification(due: string | null, body: string, badge: Badge) {
const notificationAllowed = config.get('notificationsAllowed');

Expand All @@ -40,35 +54,18 @@ function handleNotification(due: string | null, body: string, badge: Badge) {
const notificationThreshold: number = config.get('notificationThreshold');
const hash = todayString + crypto.createHash('sha256').update(body).digest('hex');
const searchFilters: SearchFilter[] = filter.get('search') || [];

let searchFilterMatch;
for (const searchFilter of searchFilters) {
if (searchFilter.notify && searchFilter.label) {
const match = checkForSearchMatches(body, searchFilter.label);
if (match) {
searchFilterMatch = {
label: searchFilter.label,
};
break;
}
}
}

if(isNotificationSuppressed(searchFilters, body)) return;

let title: string;
if(dueDate.isToday() || dueDate.isBetween(today, today.add(notificationThreshold, 'day'))) {
title = createSpeakingDifference(dueDate)
} else if(searchFilterMatch && searchFilterMatch.label) {
title = `Matched "${searchFilterMatch.label}"`;
} else {
return;
}

badge.count += 1;
const notifiedTodoObjects = new Set<string>(notifiedTodoObjectsStorage.get('notifiedTodoObjects', []));
if(!notifiedTodoObjects.has(hash)) {
sendNotification(title, body);
notifiedTodoObjects.add(hash);
notifiedTodoObjectsStorage.set('notifiedTodoObjects', Array.from(notifiedTodoObjects));
badge.count += 1;
const title = createSpeakingDifference(dueDate);
const notifiedTodoObjects = new Set<string>(notifiedTodoObjectsStorage.get('notifiedTodoObjects', []));
if(!notifiedTodoObjects.has(hash)) {
sendNotification(title, body);
notifiedTodoObjects.add(hash);
notifiedTodoObjectsStorage.set('notifiedTodoObjects', Array.from(notifiedTodoObjects));
}
}
}
}
Expand Down
20 changes: 7 additions & 13 deletions src/renderer/App.scss
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
@import "Variables.scss";
@import "Coloring.scss";

@font-face {
font-family: "FreeSans";
src: url("../../assets/fonts/FreeSans.otf") format("opentype");
src: url("../../assets/fonts/FreeSans.ttf") format("truetype");
}
@font-face {
font-family: "FreeSansBold";
src: url("../../assets/fonts/FreeSansBold.otf") format("opentype");
src: url("../../assets/fonts/FreeSansBold.ttf") format("truetype");
}

body {
overflow: hidden;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
font-family: "Helvetica, Arial, Sans-Serif";
code {
font-size: 0.9em;
background: $lighter-grey;
color: $mid-grey;
color: $dark-grey;
border-radius: 0.25em;
padding: 0.25em;
white-space: nowrap;
}
#root {
.flexContainer {
Expand Down Expand Up @@ -62,7 +56,7 @@ body {
}

h1, h2, h3, h4, h5 {
font-family: $font-family-bold;
font-weight: bold;
}

*::-webkit-scrollbar {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const App = () => {
setSearchString={setSearchString}
settings={settings}
searchFieldRef={searchFieldRef}
setPromptItem={setPromptItem}
/>
<HeaderComponent
settings={settings}
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/Drawer/Attributes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
}
h3 {
font-family: 'FreeSansBold';
font-weight: bold;
padding: 0;
margin: 0;
}
Expand Down Expand Up @@ -67,7 +67,7 @@
}
.MuiBadge-badge {
z-index: 10;
font-family: 'FreeSansBold';
font-weight: bold;
font-size: 0.75em;
}
button:disabled {
Expand All @@ -87,7 +87,7 @@
button {
min-width: 1.75em;
font-size: 1.25em;
font-family: 'FreeSansBold';
font-weight: bold;
padding: 0.1em 0.65em;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/Drawer/Filters.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
margin: 0;
overflow-y: scroll;
h3 {
font-family: 'FreeSansBold';
font-weight: bold;
padding: 0;
margin: 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/Drawer/Sorting/DraggableList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#Sorting {
padding: 0 1em;
h3 {
font-family: 'FreeSansBold';
font-weight: bold;
padding: 0;
margin: 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/Grid/Row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
min-width: auto;
min-height: auto;
font-size: 1.25em;
font-family: $font-family-bold;
font-weight: bold;
padding: 0.1em 0.6em;
border-radius: 0.65em;
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const HeaderComponent: React.FC<Props> = memo(({
const handleKeyDown = useCallback(
(event: KeyboardEvent) => {
const isSearchFocused = document.activeElement === searchFieldRef.current;
if ((event.metaKey || event.ctrlKey) && event.key === 'f' && settings.isSearchOpen && !isSearchFocused) {
if ((event.metaKey || event.ctrlKey) && !event.shiftKey && event.key === 'f' && settings.isSearchOpen && !isSearchFocused) {
event.preventDefault();
searchFieldRef.current?.focus();
}
Expand Down
5 changes: 0 additions & 5 deletions src/renderer/Header/Search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
display: flex;
position: relative;
margin-bottom: 0.25em;
.MuiButton-root {
position: absolute;
top: 0.5em;
right: 3.5em;
}
.MuiAutocomplete-root {
flex-direction: row;
flex: 1;
Expand Down
Loading

0 comments on commit 14174aa

Please sign in to comment.