Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ransome
sleek
Commits
2e5ec0be
Commit
2e5ec0be
authored
Sep 24, 2021
by
ransome1
Browse files
Fixed group header issue on lazy loading
parent
f95f6d91
Changes
9
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
2e5ec0be
{
"name"
:
"sleek"
,
"productName"
:
"sleek"
,
"version"
:
"1.1.1"
,
"version"
:
"1.1.
2-rc.
1"
,
"description"
:
"Todo app based on todo.txt for Linux, Windows and MacOS, free and open-source"
,
"synopsis"
:
"Todo app based on todo.txt for Linux, Windows and MacOS, free and open-source"
,
"category"
:
"ProjectManagement"
,
...
...
src/js/files.mjs
View file @
2e5ec0be
...
...
@@ -55,11 +55,11 @@ function selectFileFromList(index) {
handleError
(
error
);
});
resetModal
().
then
(
response
=>
{
window
.
api
.
send
(
"
startFileWatcher
"
,
[
userData
.
files
[
index
][
1
],
1
]);
console
.
info
(
response
);
}).
catch
(
error
=>
{
handleError
(
error
);
});
window
.
api
.
send
(
"
startFileWatcher
"
,
[
userData
.
files
[
index
][
1
],
1
]);
return
Promise
.
resolve
(
"
Success: File selected
"
);
}
catch
(
error
)
{
return
Promise
.
reject
(
error
);
...
...
src/js/todos.mjs
View file @
2e5ec0be
...
...
@@ -56,16 +56,16 @@ const todoTableBodyCellHiddenTemplate = document.createElement("span");
const
item
=
{
previous
:
""
}
let
items
,
clusterCounter
,
clusterSize
=
Math
.
ceil
(
window
.
innerHeight
/
3
0
),
// 3
5
being the pixel height of one todo in compact mode
clusterThreshold
=
0
,
//stopBuilding = false
,
visibleRows
=
0
;
clusterCounter
=
0
,
clusterSize
=
Math
.
ceil
(
window
.
innerHeight
/
3
2
),
// 3
2
being the pixel height of one todo in compact mode
clusterThreshold
=
clusterSize
,
visibleRows
,
todoRows
;
todoTableWrapper
.
addEventListener
(
"
scroll
"
,
function
(
event
)
{
if
(
visibleRows
>=
items
.
filtered
.
length
)
return
false
;
if
(
clusterThreshold
>=
items
.
filtered
.
length
)
return
false
;
if
(
Math
.
floor
(
event
.
target
.
scrollHeight
-
event
.
target
.
scrollTop
)
<=
event
.
target
.
clientHeight
)
{
//
stopBuilding = false
;
//
clusterThreshold = clusterThreshold + clusterCounter
;
startBuilding
(
true
);
}
});
...
...
@@ -89,15 +89,8 @@ function showResultStats() {
return
Promise
.
reject
(
error
);
}
}
function
configureTodoTableTemplate
(
append
)
{
function
configureTodoTableTemplate
()
{
try
{
// setting up for the first cluster
if
(
!
append
)
{
todoTable
.
innerHTML
=
""
;
visibleRows
=
0
;
clusterThreshold
=
0
;
//stopBuilding = false;
}
todoTableBodyRowTemplate
.
setAttribute
(
"
class
"
,
"
todo
"
);
todoTableBodyCellCheckboxTemplate
.
setAttribute
(
"
class
"
,
"
cell checkbox
"
);
todoTableBodyCellTextTemplate
.
setAttribute
(
"
class
"
,
"
cell text
"
);
...
...
@@ -166,19 +159,19 @@ function generateGroups(items) {
});
return
Promise
.
resolve
(
items
)
}
async
function
generateTable
(
groups
,
append
,
loadAll
)
{
async
function
generateTable
(
groups
,
loadAll
)
{
try
{
todoRows
=
new
Array
;
// TODO Overthink due to performance reasons
todoTable
.
textContent
=
""
;
// configure stats
showResultStats
();
// prepare the templates for the table
await
configureTodoTableTemplate
(
append
);
await
configureTodoTableTemplate
();
// reset cluster count for this run
clusterCounter
=
0
;
for
(
let
group
in
groups
)
{
// if(stopBuilding) {
// stopBuilding = false;
// break;
// }
// create a divider row
let
dividerRow
;
// completed todos
...
...
@@ -202,19 +195,9 @@ async function generateTable(groups, append, loadAll) {
}
else
{
dividerRow
=
document
.
createRange
().
createContextualFragment
(
"
<div class=
\"
group
\"
></div>
"
)
}
// add divider row only if it doesn't exist yet
if
(
!
append
&&
!
document
.
getElementById
(
userData
.
sortBy
[
0
]
+
groups
[
group
][
0
])
&&
dividerRow
)
tableContainerContent
.
appendChild
(
dividerRow
);
if
(
!
document
.
getElementById
(
userData
.
sortBy
[
0
]
+
groups
[
group
][
0
])
&&
dividerRow
)
todoRows
.
push
(
dividerRow
);
for
(
let
item
in
groups
[
group
][
1
])
{
let
todo
=
groups
[
group
][
1
][
item
];
//TODO: Explain this, maybe refactor
if
(
!
loadAll
&&
clusterCounter
<
clusterThreshold
)
{
clusterCounter
++
;
continue
;
}
else
if
(
!
loadAll
&&
(
visibleRows
===
clusterSize
+
clusterThreshold
)
||
visibleRows
===
items
.
filtered
.
length
)
{
clusterThreshold
=
visibleRows
;
//stopBuilding = true;
break
;
}
// if this todo is not a recurring one the rec value will be set to null
if
(
!
todo
.
rec
)
todo
.
rec
=
null
;
// incompleted todos with due date
...
...
@@ -234,8 +217,20 @@ async function generateTable(groups, append, loadAll) {
});
}
}
tableContainerContent
.
appendChild
(
generateTableRow
(
todo
));
todoRows
.
push
(
generateTableRow
(
todo
));
}
}
for
(
let
row
in
todoRows
)
{
clusterCounter
++
;
visibleRows
++
;
if
(
clusterCounter
===
clusterThreshold
)
{
clusterThreshold
=
clusterThreshold
+
clusterCounter
;
clusterCounter
=
0
;
break
;
}
else
if
(
visibleRows
<
clusterThreshold
)
{
continue
;
}
tableContainerContent
.
appendChild
(
todoRows
[
row
]);
}
todoTable
.
appendChild
(
tableContainerContent
);
return
Promise
.
resolve
(
"
Success: Todo table generated
"
);
...
...
@@ -246,8 +241,6 @@ async function generateTable(groups, append, loadAll) {
}
function
generateTableRow
(
todo
)
{
try
{
clusterCounter
++
;
visibleRows
++
;
// create nodes from templates
let
todoTableBodyRow
=
todoTableBodyRowTemplate
.
cloneNode
(
true
);
let
todoTableBodyCellCheckbox
=
todoTableBodyCellCheckboxTemplate
.
cloneNode
(
true
);
...
...
@@ -647,4 +640,4 @@ function generateHash(string) {
(((
prevHash
<<
5
)
-
prevHash
)
+
currVal
.
charCodeAt
(
0
))
|
0
,
0
);
}
export
{
generateItems
,
generateGroups
,
generateTable
,
items
,
item
,
visibleRows
,
setTodoComplete
,
archiveTodos
,
addTodo
};
export
{
generateItems
,
generateGroups
,
generateTable
,
items
,
item
,
setTodoComplete
,
archiveTodos
,
addTodo
};
src/main.js
View file @
2e5ec0be
...
...
@@ -167,7 +167,7 @@ const createWindow = async function() {
break
;
}
}
const
startFileWatcher
=
function
(
file
,
isTabItem
)
{
const
startFileWatcher
=
function
(
file
,
isTabItem
,
resetTab
)
{
try
{
if
(
!
fs
.
existsSync
(
file
))
throw
(
"
Error: File not found on disk
"
)
// skip persisted files and go with ENV if set
...
...
src/render.js
View file @
2e5ec0be
...
...
@@ -785,7 +785,7 @@ function getBadgeCount() {
});
return
count
;
}
async
function
startBuilding
(
append
,
loadAll
)
{
async
function
startBuilding
(
loadAll
)
{
try
{
t0
=
performance
.
now
();
...
...
@@ -798,7 +798,7 @@ async function startBuilding(append, loadAll) {
userData
=
await
getUserData
();
await
todos
.
generateTable
(
groups
,
append
,
loadAll
);
await
todos
.
generateTable
(
groups
,
loadAll
);
configureMainView
();
...
...
test/preferences_empty/todo_done.txt
View file @
2e5ec0be
...
...
@@ -8,3 +8,4 @@ x 2021-07-15 2021-07-15 test todo
x 2021-07-17 2021-07-17 test todo
x 2021-07-25 2021-07-25 test todo
x 2021-07-27 2021-07-27 test todo
x 2021-09-24 2021-09-24 test todo
test/preferences_empty/user-preferences.json
View file @
2e5ec0be
{
"theme"
:
"light"
,
"width"
:
1538
,
"height"
:
863
,
"horizontal"
:
145
,
"vertical"
:
548
,
"maximizeWindow"
:
false
,
"notifications"
:
true
,
"useTextarea"
:
false
,
"compactView"
:
false
,
"matomoEvents"
:
false
,
"drawerWidth"
:
"500"
,
"showDueIsPast"
:
true
,
"showDueIsFuture"
:
true
,
"showDueIsToday"
:
true
,
"showHidden"
:
false
,
"showCompleted"
:
true
,
"sortCompletedLast"
:
false
,
"sortBy"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"zoom"
:
"100"
,
"tray"
:
false
,
"showEmptyFilters"
:
true
,
"dismissedNotifications"
:[
-1319247018
],
"dismissedMessages"
:[],
"hideFilterCategories"
:[],
"language"
:
"en"
,
"uid"
:
"TESTING"
,
"path"
:
"test/preferences_empty/todo.txt"
,
"files"
:[[
1
,
"test/preferences_empty/todo.txt"
]],
"file"
:
"test/preferences_empty/todo.txt"
,
"filterDrawer"
:
false
,
"selectedFilters"
:[],
"viewDrawer"
:
false
,
"sortByLevel"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"deferredTodos"
:
true
,
"fileTabs"
:
true
}
\ No newline at end of file
{
"theme"
:
"light"
,
"width"
:
1538
,
"height"
:
863
,
"horizontal"
:
145
,
"vertical"
:
577
,
"maximizeWindow"
:
false
,
"notifications"
:
true
,
"useTextarea"
:
false
,
"compactView"
:
false
,
"matomoEvents"
:
false
,
"drawerWidth"
:
"500"
,
"showDueIsPast"
:
true
,
"showDueIsFuture"
:
true
,
"showDueIsToday"
:
true
,
"showHidden"
:
false
,
"showCompleted"
:
true
,
"sortCompletedLast"
:
false
,
"sortBy"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"zoom"
:
"100"
,
"tray"
:
false
,
"showEmptyFilters"
:
true
,
"dismissedNotifications"
:[
-1319247018
],
"dismissedMessages"
:[],
"hideFilterCategories"
:[],
"language"
:
"en"
,
"uid"
:
"TESTING"
,
"path"
:
"test/preferences_empty/todo.txt"
,
"files"
:[[
1
,
"test/preferences_empty/todo.txt"
]],
"file"
:
"test/preferences_empty/todo.txt"
,
"filterDrawer"
:
false
,
"selectedFilters"
:[],
"viewDrawer"
:
false
,
"sortByLevel"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"deferredTodos"
:
true
,
"fileTabs"
:
true
}
\ No newline at end of file
test/preferences_existent/user-preferences.json
View file @
2e5ec0be
{
"theme"
:
"light"
,
"width"
:
1538
,
"height"
:
863
,
"horizontal"
:
46
,
"vertical"
:
29
,
"maximizeWindow"
:
true
,
"notifications"
:
true
,
"useTextarea"
:
false
,
"compactView"
:
false
,
"matomoEvents"
:
false
,
"drawerWidth"
:
"500"
,
"showDueIsPast"
:
true
,
"showDueIsFuture"
:
true
,
"showDueIsToday"
:
true
,
"showHidden"
:
false
,
"showCompleted"
:
true
,
"sortCompletedLast"
:
false
,
"sortBy"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"zoom"
:
"100"
,
"tray"
:
false
,
"showEmptyFilters"
:
true
,
"dismissedNotifications"
:[
-1319247018
],
"dismissedMessages"
:[],
"hideFilterCategories"
:[],
"language"
:
"en"
,
"uid"
:
"TESTING"
,
"path"
:
"test/preferences_existent/todo.txt"
,
"files"
:[[
1
,
"test/preferences_existent/todo.txt"
]],
"file"
:
"test/preferences_existent/todo.txt"
,
"filterDrawer"
:
false
,
"selectedFilters"
:[],
"viewDrawer"
:
false
,
"sortByLevel"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"deferredTodos"
:
true
,
"fileTabs"
:
true
}
\ No newline at end of file
{
"theme"
:
"light"
,
"width"
:
1538
,
"height"
:
863
,
"horizontal"
:
46
,
"vertical"
:
389
,
"maximizeWindow"
:
true
,
"notifications"
:
true
,
"useTextarea"
:
false
,
"compactView"
:
false
,
"matomoEvents"
:
false
,
"drawerWidth"
:
"500"
,
"showDueIsPast"
:
true
,
"showDueIsFuture"
:
true
,
"showDueIsToday"
:
true
,
"showHidden"
:
false
,
"showCompleted"
:
true
,
"sortCompletedLast"
:
false
,
"sortBy"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"zoom"
:
"100"
,
"tray"
:
false
,
"showEmptyFilters"
:
true
,
"dismissedNotifications"
:[
-1319247018
],
"dismissedMessages"
:[],
"hideFilterCategories"
:[],
"language"
:
"en"
,
"uid"
:
"TESTING"
,
"path"
:
"test/preferences_existent/todo.txt"
,
"files"
:[[
1
,
"test/preferences_existent/todo.txt"
]],
"file"
:
"test/preferences_existent/todo.txt"
,
"filterDrawer"
:
false
,
"selectedFilters"
:[],
"viewDrawer"
:
false
,
"sortByLevel"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"deferredTodos"
:
true
,
"fileTabs"
:
true
}
\ No newline at end of file
test/preferences_fresh/user-preferences.json
View file @
2e5ec0be
{
"theme"
:
"light"
,
"width"
:
1100
,
"height"
:
700
,
"horizontal"
:
129
,
"vertical"
:
525
,
"maximizeWindow"
:
false
,
"notifications"
:
true
,
"useTextarea"
:
false
,
"compactView"
:
false
,
"matomoEvents"
:
false
,
"drawerWidth"
:
"500"
,
"showDueIsPast"
:
true
,
"showDueIsFuture"
:
true
,
"showDueIsToday"
:
true
,
"showHidden"
:
false
,
"showCompleted"
:
true
,
"sortCompletedLast"
:
false
,
"sortBy"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"zoom"
:
"100"
,
"tray"
:
false
,
"showEmptyFilters"
:
true
,
"hideFilterCategories"
:[],
"language"
:
"en"
,
"dismissedNotifications"
:[],
"dismissedMessages"
:[],
"sortByLevel"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"deferredTodos"
:
true
,
"fileTabs"
:
true
}
\ No newline at end of file
{
"theme"
:
"light"
,
"width"
:
1100
,
"height"
:
700
,
"horizontal"
:
129
,
"vertical"
:
670
,
"maximizeWindow"
:
false
,
"notifications"
:
true
,
"useTextarea"
:
false
,
"compactView"
:
false
,
"matomoEvents"
:
false
,
"drawerWidth"
:
"500"
,
"showDueIsPast"
:
true
,
"showDueIsFuture"
:
true
,
"showDueIsToday"
:
true
,
"showHidden"
:
false
,
"showCompleted"
:
true
,
"sortCompletedLast"
:
false
,
"sortBy"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"zoom"
:
"100"
,
"tray"
:
false
,
"showEmptyFilters"
:
true
,
"hideFilterCategories"
:[],
"language"
:
"en"
,
"dismissedNotifications"
:[],
"dismissedMessages"
:[],
"sortByLevel"
:[
"priority"
,
"dueString"
,
"contexts"
,
"projects"
],
"deferredTodos"
:
true
,
"fileTabs"
:
true
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment