Skip to content

Commit

Permalink
Added a prove of concept how "search filters" could work
Browse files Browse the repository at this point in the history
  • Loading branch information
ransome1 committed Jan 13, 2024
1 parent 0500409 commit 4ae30f5
Show file tree
Hide file tree
Showing 15 changed files with 199 additions and 110 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.7" date="2024-01-12"/>
<release version="2.0.7-rc.1" date="2024-01-13"/>
</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
Version=2.0.7-rc.1
Name=sleek
Exec=sleek
Type=Application
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sleek",
"version": "2.0.7",
"version": "2.0.7-rc.1",
"main": "./src/main/main.tsx",
"scripts": {
"build": "concurrently \"yarn run peggy\" \"yarn run build:main\" \"yarn run build:renderer\"",
Expand Down Expand Up @@ -80,8 +80,6 @@
"electron-store": "^8.1.0",
"i18next": "^23.5.1",
"jstodotxt": "^1.0.0-alpha.0",
"material-ui-popup-state": "^5.0.9",
"peggy": "^3.0.2",
"react": "^18.2.0",
"react-autosuggest": "^10.1.0",
"react-beautiful-dnd": "^13.1.1",
Expand Down Expand Up @@ -120,7 +118,9 @@
"html-webpack-plugin": "^5.5.1",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"material-ui-popup-state": "^5.0.9",
"mini-css-extract-plugin": "^2.7.6",
"peggy": "^3.0.2",
"prettier": "^3.1.1",
"react-refresh": "^0.14.0",
"react-test-renderer": "^18.2.0",
Expand All @@ -142,7 +142,7 @@
"webpack-merge": "^5.9.0"
},
"build": {
"buildVersion": "35",
"buildVersion": "37",
"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.7",
"version": "2.0.7-rc.1",
"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"
version: "2.0.7-rc.1"
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
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 @@

2024-01-12 Line 1 rec:1d due:2024-01-13
2024-01-12 Line 1 rec:w due:2024-01-19
2024-01-12 Line 1 rec:2m due:2024-03-12
2024-01-12 Line 1 rec:+1d due:2024-01-14
2024-01-12 Line 1 rec:7w due:2024-03-01
2024-01-12 Line 1 due:2023-07-24 rec:+1b
2024-01-12 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y
2024-01-12 Water plants @home +quick due:2024-01-19 t:2024-01-09 rec:1w
2024-01-12 Line 1 rec:+1d t:2023-09-20
2024-01-12 Line 1 rec:1d pri:A due:2024-01-13
2024-01-12 (A) Do something rec:d t:2024-01-13 @SomeContext
2024-01-12 Do something rec:0d
2024-01-12 Do something rec:0d due:2024-01-12
2024-01-12 Do something rec:0d due:2024-01-12 t:2024-01-12
2024-01-13 Line 1 rec:1d due:2024-01-14
2024-01-13 Line 1 rec:w due:2024-01-20
2024-01-13 Line 1 rec:2m due:2024-03-13
2024-01-13 Line 1 rec:+1d due:2024-01-15
2024-01-13 Line 1 rec:7w due:2024-03-02
2024-01-13 Line 1 due:2023-07-24 rec:+1b
2024-01-13 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y
2024-01-13 Water plants @home +quick due:2024-01-20 t:2024-01-10 rec:1w
2024-01-13 Line 1 rec:+1d t:2023-09-20
2024-01-13 Line 1 rec:1d pri:A due:2024-01-14
2024-01-13 (A) Do something rec:d t:2024-01-14 @SomeContext
2024-01-13 Do something rec:0d
2024-01-13 Do something rec:0d due:2024-01-13
2024-01-13 Do something rec:0d due:2024-01-13 t:2024-01-13
9 changes: 5 additions & 4 deletions src/main/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ const configStorage: Store<Settings> = new Store<Settings>({
});

const filtersPath = path.join(userDataDirectory, 'filters.json');
const filterStorage = new Store<{}>({ cwd: userDataDirectory, name: 'filters' });
const filterStorage = new Store<Filters>({ cwd: userDataDirectory, name: 'filters' });

if(!fs.existsSync(filtersPath)) {
const defaultFilterData = {};
fs.writeFileSync(filtersPath, JSON.stringify(defaultFilterData));
if(!filterStorage.has('search')) {
filterStorage.set('search', []);
} else if(!filterStorage.has('attributes')) {
filterStorage.set('attributes', {});
}

const notifiedTodoObjectsPath = path.join(userDataDirectory, 'notifiedTodoObjects.json');
Expand Down
19 changes: 17 additions & 2 deletions src/main/modules/IpcMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,18 @@ function handleStoreSetConfig(event: IpcMainEvent, key: string, value: any) {
}
}

function handleStoreSetFilters(event: IpcMainEvent, value: any): void {
function handleStoreSetFilters(event: IpcMainEvent, key: string, value: any): void {
try {
filterStorage.set('filters', value);
filterStorage.set(key, value);
} catch (error: any) {
console.error(error);
event.reply('responseFromMainProcess', error);
}
}

function handleStoreGetFilters(event: IpcMainEvent, value: string): void {
try {
event.returnValue = filterStorage.get(value);
} catch (error: any) {
console.error(error);
event.reply('responseFromMainProcess', error);
Expand Down Expand Up @@ -203,6 +212,9 @@ function removeEventListeners(): void {
ipcMain.off('storeGetConfig', handleStoreGetConfig);
ipcMain.off('storeSetConfig', handleStoreSetConfig);
ipcMain.off('storeSetFilters', handleStoreSetFilters);

ipcMain.off('storeGetFilters', handleStoreGetFilters);

ipcMain.off('storeSetNotifiedTodoObjects', handleStoreSetNotifiedTodoObjects);
ipcMain.off('setFile', handleSetFile);
ipcMain.off('removeFile', handleRemoveFile);
Expand All @@ -227,6 +239,9 @@ app.on('before-quit', () => removeEventListeners);
ipcMain.on('storeGetConfig', handleStoreGetConfig);
ipcMain.on('storeSetConfig', handleStoreSetConfig);
ipcMain.on('storeSetFilters', handleStoreSetFilters);

ipcMain.on('storeGetFilters', handleStoreGetFilters);

ipcMain.on('storeSetNotifiedTodoObjects', handleStoreSetNotifiedTodoObjects);
ipcMain.on('setFile', handleSetFile);
ipcMain.on('removeFile', handleRemoveFile);
Expand Down
2 changes: 1 addition & 1 deletion src/main/modules/ProcessDataRequest/ProcessDataRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function processDataRequest(search?: string): Promise<void> {
const sorting: Sorting[] = configStorage.get('sorting');
const showHidden: boolean = configStorage.get('showHidden');
const fileSorting: boolean = configStorage.get('fileSorting');
const filters: Filters = filterStorage.get('filters');
const filters: Filters = filterStorage.get('attributes');

const fileContent = await readFileContent(activeFile.todoFilePath, activeFile.todoFileBookmark);
let todoObjects: TodoObject[] | [] = await createTodoObjects(fileContent);
Expand Down
7 changes: 5 additions & 2 deletions src/main/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ contextBridge.exposeInMainWorld('api', {
set(property, value) {
ipcRenderer.send('storeSetConfig', property, value);
},
setFilters(value) {
ipcRenderer.send('storeSetFilters', value);
setFilters(property, value) {
ipcRenderer.send('storeSetFilters', property, value);
},
getFilters(key) {
return ipcRenderer.sendSync('storeGetFilters', key);
},
notifiedTodoObjects(value) {
ipcRenderer.send('storeSetNotifiedTodoObjects', value);
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/Dialog/AutoSuggest.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
padding: 1em;
display: block;
border-radius: $radius;
background-color: rgba(240, 240, 240, 0.85);
background-color: rgba(240, 240, 240, 1);
ul {
padding: 0;
margin: 0;
Expand All @@ -26,6 +26,6 @@

.darkTheme {
.react-autosuggest__suggestions-container--open {
background-color: rgba(45, 45, 45, 0.85);
background-color: rgba(45, 45, 45, 1);
}
}
59 changes: 20 additions & 39 deletions src/renderer/Header/Search.scss
Original file line number Diff line number Diff line change
@@ -1,49 +1,30 @@
@import "../Variables.scss";

#Search {
height: 3em;
min-height: 3em;
display: flex;
overflow: hidden;
.MuiTextField-root {
position: relative;
margin-bottom: 0.25em;
.MuiButton-root {
position: absolute;
top: 0.5em;
right: 3.5em;
}
.MuiAutocomplete-root {
flex-direction: row;
flex: 1;
margin: 0.25em 1em;
.MuiInputBase-root {
flex: 1;
padding-right: 3em;
.MuiInputBase-input {
height: 100%;
padding: 0;
margin: 1em;
}
.MuiButtonBase-root {
font-size: 0.9em;
padding: 0.2em 0.5em;
background: $dark-grey;
}
.MuiButtonBase-root.Mui-focusVisible {
background: $blue;
}
button.xClick {
padding: $radius;
cursor: pointer;
border: none;
outline: none;
background: transparent;
svg {
color: $dark-grey;
}
}
button.xClick:focus-visible {
svg {
color: $blue;
}
}
button.xClick:focus {
margin: 0 1em 0.25em 1em;
}
}

.MuiAutocomplete-popper {
.MuiPaper-root {
margin-top: 0.125em;
box-shadow: none;
.MuiAutocomplete-listbox {
svg {
color: $blue;
outline: none;
}
margin-right: 0.5em;
}
}
}
}
Loading

0 comments on commit 4ae30f5

Please sign in to comment.