Skip to content

WIP Feat/sync lib #4256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 271 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
271 commits
Select commit Hold shift + click to select a range
b2bd4f7
feat(pfapi): outline actual integration and fix alot of errors
johannesjo Mar 17, 2025
3ee4f55
feat(pfapi): make super basic data uploading work
johannesjo Mar 17, 2025
cd5fda1
feat(pfapi): add decryption compression interface
johannesjo Mar 17, 2025
c665db4
feat(pfapi): outline client id generation
johannesjo Mar 17, 2025
1515a71
feat(pfapi): wip private credential store
johannesjo Mar 17, 2025
6786e3e
feat(pfapi): solve namespacing much better
johannesjo Mar 18, 2025
8c0abaf
feat(pfapi): improve structure
johannesjo Mar 18, 2025
4f4a11f
feat(pfapi): improve logging
johannesjo Mar 18, 2025
7b6cf28
feat(pfapi): make sync credential store work
johannesjo Mar 18, 2025
2513b2b
feat(pfapi): extract string values
johannesjo Mar 18, 2025
d407d67
feat(pfapi): implement lock file
johannesjo Mar 18, 2025
e00781b
feat(pfapi): improve database
johannesjo Mar 18, 2025
f7c1d3b
feat(pfapi): wip make stuff work halfway
johannesjo Mar 18, 2025
ab80273
feat(pfapi): make get model ids to update work better
johannesjo Mar 19, 2025
e9f7542
feat(pfapi): prepare getSyncStatusFromMetaFiles
johannesjo Mar 19, 2025
57c2522
feat(pfapi): improve error handling
johannesjo Mar 19, 2025
01b0719
feat(pfapi): make sync status work
johannesjo Mar 19, 2025
cb29307
feat(pfapi): improve logging and credentials store
johannesjo Mar 19, 2025
135f82f
feat(pfapi): split up local and remote meta types and make most basic…
johannesjo Mar 19, 2025
e53e0ef
feat(pfapi): outline update local
johannesjo Mar 19, 2025
4314a47
feat(pfapi): outline using pfapi for all models
johannesjo Mar 19, 2025
48ba8da
feat(pfapi): improve pfapi as persistence provider
johannesjo Mar 19, 2025
040f783
feat(pfapi): make basic auth flow work for dropbox
johannesjo Mar 19, 2025
b2fb6dd
feat(pfapi): prepare conflict resolution
johannesjo Mar 19, 2025
688e664
feat(pfapi): prepare data import
johannesjo Mar 19, 2025
dd4eb58
feat(pfapi): make execAction and getById work again
johannesjo Mar 20, 2025
50001c1
feat(pfapi): use pfapiService instead of persistence
johannesjo Mar 20, 2025
fec3255
feat(pfapi): replace persistenceService completely with pfapi
johannesjo Mar 20, 2025
f216a0b
feat(pfapi): improve pfapi service
johannesjo Mar 20, 2025
56c3396
fix: bootstrap
johannesjo Mar 20, 2025
18e12c7
feat(pfapi): clean logs
johannesjo Mar 20, 2025
ecd43ab
feat(pfapi): detect too many requests case and prepare upload all stuff
johannesjo Mar 20, 2025
fb489ec
feat(pfapi): add load balancing and too many request handling
johannesjo Mar 20, 2025
4262738
feat(pfapi): prepare fixing dataImport service
johannesjo Mar 20, 2025
ce0475e
feat(pfapi): make clear clearDatabaseExceptLocalOnly work
johannesjo Mar 20, 2025
b767549
feat(pfapi): make updating local data work
johannesjo Mar 20, 2025
1ddfcd1
feat(pfapi): improve sync error handling
johannesjo Mar 20, 2025
7689595
feat(pfapi): improve on various sync cases
johannesjo Mar 20, 2025
b121d8a
feat(pfapi): make legacy data import work
johannesjo Mar 21, 2025
ff88f81
feat(pfapi): speed up things as much as possible
johannesjo Mar 21, 2025
3686c33
feat(pfapi): implement basic webdav
johannesjo Mar 21, 2025
87b5875
feat(pfapi): make basic webdav work
johannesjo Mar 21, 2025
005ca99
feat(pfapi): outline cascading mode
johannesjo Mar 21, 2025
0533e36
feat(pfapi): add cool fast main file mode
johannesjo Mar 21, 2025
0fdc6e1
feat(pfapi): make edge cases work
johannesjo Mar 21, 2025
ba99fa6
feat(pfapi): make it work for firefox
johannesjo Mar 21, 2025
7b128e6
feat(pfapi): reduce lgos
johannesjo Mar 22, 2025
113702d
feat(pfapi): fix webdav revs case
johannesjo Mar 22, 2025
2b696a3
feat(pfapi): fix another sync problem case
johannesjo Mar 22, 2025
93ae1aa
feat(pfapi): restructure files
johannesjo Mar 22, 2025
32df74b
feat(pfapi): make rev model update work as it should
johannesjo Mar 22, 2025
069b4f3
feat(pfapi): prepare validation
johannesjo Mar 22, 2025
efd36cb
feat(pfapi): prepare validation and data repair
johannesjo Mar 22, 2025
490018d
feat(pfapi): remove data import service completely
johannesjo Mar 22, 2025
0a0a6d8
feat(pfapi): improve on imex view service
johannesjo Mar 22, 2025
9416ac3
feat(pfapi): also validate data before providing backup
johannesjo Mar 22, 2025
ff507ef
feat(pfapi): improve backup handling
johannesjo Mar 22, 2025
ad3cad6
feat(pfapi): rename
johannesjo Mar 22, 2025
d0bddde
feat(pfapi): handle taskArchive edge case
johannesjo Mar 22, 2025
44f3988
feat(pfapi): make sure sync model data is valid
johannesjo Mar 22, 2025
196d041
feat(pfapi): improve provider init
johannesjo Mar 22, 2025
da45494
feat(pfapi): remove imex view handling for now
johannesjo Mar 22, 2025
ad8ad3b
feat(pfapi): make isCurrentProviderInSync$ work
johannesjo Mar 22, 2025
ac99338
feat(pfapi): outline local file sync as provider
johannesjo Mar 22, 2025
0c307df
feat(pfapi): make super basic electron file sync work
johannesjo Mar 22, 2025
d7def28
feat(pfapi): make removing files work for local file sync
johannesjo Mar 23, 2025
5c4b6cb
feat(pfapi): prevent electron to hang on startup
johannesjo Mar 23, 2025
a862f5e
feat(pfapi): prepare better handling of credentials
johannesjo Mar 23, 2025
40275ae
feat(pfapi): rename credentials to private cfg
johannesjo Mar 24, 2025
a64536d
feat(pfapi): make saving private sync settings work
johannesjo Mar 24, 2025
bb0b57e
feat(pfapi): improve on configuring and saving the different types of…
johannesjo Mar 24, 2025
6eae2e9
feat(pfapi): make life updates for sync form work
johannesjo Mar 24, 2025
9f47035
feat(pfapi): make initial sync work again
johannesjo Mar 24, 2025
65ad786
feat(pfapi): make encryption work
johannesjo Mar 24, 2025
8eae3dc
feat(pfapi): make compression work
johannesjo Mar 24, 2025
56ab3cd
feat(pfapi): prevent full data from bein uploaded to meta file
johannesjo Mar 25, 2025
a461f60
feat(pfapi): move task repeat stuff to main file model
johannesjo Mar 25, 2025
9257986
feat(pfapi): outline model version check
johannesjo Mar 25, 2025
8203080
feat(pfapi): improve etag handling for webdav
johannesjo Mar 25, 2025
6d13abc
feat(pfapi): prepare cors skip headers for calendar requests
johannesjo Mar 25, 2025
3d67cd8
feat(pfapi): add custom webdav implementation
johannesjo Mar 25, 2025
1182f41
feat(pfapi): improve on custom webdav solution to use head instead of…
johannesjo Mar 25, 2025
88c25c6
feat(pfapi): improve error structure
johannesjo Mar 26, 2025
646d639
feat(pfapi): improve webdav error handling
johannesjo Mar 26, 2025
0e18e35
feat(pfapi): further improve webdav error handling
johannesjo Mar 26, 2025
155d3cb
feat(pfapi): further improve webdav error handling 2
johannesjo Mar 26, 2025
2ec5490
feat(pfapi): remove axios dependency from dropbox api
johannesjo Mar 26, 2025
0f8769c
feat(pfapi): improve error handling for dropbox api
johannesjo Mar 26, 2025
12d1307
feat(pfapi): improve error handling for dropbox api
johannesjo Mar 26, 2025
463e1dc
feat(pfapi): deal with sync edge case
johannesjo Mar 26, 2025
4b81ac5
feat(pfapi): add If None match to file rev request
johannesjo Mar 26, 2025
669da0d
feat(pfapi): improve android dropbox
johannesjo Mar 26, 2025
2e4bea0
feat(pfapi): implement local file sync for android
johannesjo Mar 26, 2025
b03cfcd
feat(pfapi): improve error and tmp backup handling
johannesjo Mar 27, 2025
34197e5
feat(pfapi): make complete data import work
johannesjo Mar 27, 2025
ff3d40d
feat(pfapi): implement db lock to avoid problems during complete import
johannesjo Mar 27, 2025
3867809
feat(pfapi): make file import work again as it should
johannesjo Mar 27, 2025
8cdd24e
feat(pfapi): prepare better android file sync
johannesjo Mar 27, 2025
a8de103
feat(pfapi): make android file sync work
johannesjo Mar 27, 2025
e50c22d
feat(pfapi): work around initial load problem on android and electron
johannesjo Mar 27, 2025
691123d
feat(pfapi): improve on pfapi init
johannesjo Mar 27, 2025
c538c5b
feat(pfapi): improve on snack
johannesjo Mar 27, 2025
c8dc21a
feat(pfapi): use md5 hash also for electron file sync
johannesjo Mar 27, 2025
0e59ff7
feat(pfapi): improve electron file sync
johannesjo Mar 27, 2025
b4e627e
feat(pfapi): improve file sync
johannesjo Mar 27, 2025
d58d5d7
feat(pfapi): improve initial experience for electron file sync
johannesjo Mar 27, 2025
a760cb0
feat(pfapi): remove multi file mode to make things easier
johannesjo Mar 28, 2025
cdd3ab7
refactor(pfapi): remove unnecessary assignments
johannesjo Mar 28, 2025
584882d
feat(pfapi): use meta file as lock file replacement
johannesjo Mar 28, 2025
f61e58b
refactor(pfapi): to getter
johannesjo Mar 28, 2025
1e13c66
feat(pfapi): implement one file sync for local file sync providers
johannesjo Mar 28, 2025
8c5ed3e
feat(pfapi): improve sync button state
johannesjo Mar 28, 2025
7f1f9ef
refactor(pfapi): improve sync service
johannesjo Mar 28, 2025
91cdf9f
feat(pfapi): improve isSyncInProgress$ and global spinner handling
johannesjo Mar 28, 2025
0bc89eb
feat(pfapi): implement rev map check
johannesjo Mar 28, 2025
44b362c
feat(pfapi): handle all incomplete sync cases
johannesjo Mar 28, 2025
50c49f0
feat(pfapi): implement transformBeforeUpload
johannesjo Mar 28, 2025
904c5e2
feat(pfapi): implement transformBeforeDownload
johannesjo Mar 28, 2025
4ddbbba
feat(pfapi): make app reload model changes after downloading remote
johannesjo Mar 29, 2025
bb55c04
feat(pfapi): add snack info when importing data from remote
johannesjo Mar 29, 2025
a34d427
refactor(pfapi): extract meta file service from sync service
johannesjo Mar 29, 2025
4709f4f
refactor(pfapi): extract model sync service from sync service
johannesjo Mar 29, 2025
e76cec0
refactor(pfapi): further extract stuff from sync.service
johannesjo Mar 29, 2025
96172de
feat(pfapi): outline new time tracking model
johannesjo Mar 29, 2025
1b127ea
feat(pfapi): make sync trigger work again
johannesjo Mar 29, 2025
c06f0a2
feat(pfapi): remove legacy stuff for sync
johannesjo Mar 29, 2025
6f1b894
feat(pfapi): make migration work
johannesjo Mar 29, 2025
bae3879
feat(pfapi): remove alert
johannesjo Mar 29, 2025
b1c1f8f
feat(pfapi): improve
johannesjo Mar 29, 2025
fbb5d0a
test(pfapi): add some basic unit tests
johannesjo Mar 29, 2025
5c4c99b
test(pfapi): add lots of tests
johannesjo Mar 30, 2025
6d642d8
refactor(pfapi): rename syncService to syncWrapperService
johannesjo Mar 30, 2025
394f652
test(pfapi): add for ModelSyncService
johannesjo Mar 30, 2025
7758b28
build: update package-lock.json
johannesjo Mar 31, 2025
0df2475
feat(pfapi): implement different sync folder for dev
johannesjo Mar 31, 2025
0aa89b3
test(pfapi): minor adjustment
johannesjo Mar 31, 2025
cb2c556
feat(pfapi): improve migration experience for electron
johannesjo Mar 31, 2025
5fd88ec
feat(pfapi): improve migration experience 2 #4137
johannesjo Mar 31, 2025
5e89a62
fix: input duration directive not working as expected
johannesjo Mar 31, 2025
2912143
refactor(pfapi): cleanup sync form
johannesjo Apr 1, 2025
eae4ea4
feat(timeTracking): outline new state
johannesjo Apr 1, 2025
f818367
feat: remove android permanent notification stuff
johannesjo Apr 1, 2025
ec4a08a
feat(timeTracking): migrate project and tag to new model 1
johannesjo Apr 1, 2025
cd1ecf5
feat(timeTracking): prepare pfapi stuff for migration
johannesjo Apr 1, 2025
b584c82
feat(timeTracking): prepare pfapi stuff for migration
johannesjo Apr 1, 2025
cfa6814
feat(timeTracking): make store stuff work for new project/tag
johannesjo Apr 1, 2025
cf20e14
feat(timeTracking): make persisting data work as it should
johannesjo Apr 1, 2025
8990e95
feat(timeTracking): also make break stuff to tt model
johannesjo Apr 1, 2025
38fcb10
feat(timeTracking): minimize disk space usage
johannesjo Apr 1, 2025
c245088
feat(timeTracking): improve merging code
johannesjo Apr 1, 2025
03534d4
feat(timeTracking): outline cross model migrations
johannesjo Apr 1, 2025
b583caa
test(timeTracking): make them work again
johannesjo Apr 2, 2025
d875063
test(timeTracking): make migration work for project and tag
johannesjo Apr 2, 2025
a0e0b22
feat(timeTracking): make TTWorkContextData members optional (to save …
johannesjo Apr 2, 2025
0c05311
feat(pfapi): extract migrate stuff into its own service
johannesjo Apr 2, 2025
23a00d2
feat(pfapi): add migration before importing complete data and during …
johannesjo Apr 2, 2025
e5ec28e
feat(timeTracking): slightly improve stats fallback
johannesjo Apr 2, 2025
5441bba
feat(timeTracking): move addTimeSpent to timeTracking actions
johannesjo Apr 2, 2025
6127c0e
fix(timeTracking): reduce number of disk writes by at least 15x #2355…
johannesjo Apr 2, 2025
f18a0b6
feat(timeTracking): outline flush to archive mechanism
johannesjo Apr 2, 2025
4c7b1d4
update t.const.ts
johannesjo Apr 3, 2025
85affac
cleanup local backup module
johannesjo Apr 3, 2025
d5ef1d8
feat(timeTracking): implement new taskArchive service
johannesjo Apr 3, 2025
a2bdd2b
feat(timeTracking): improve new taskArchiveService
johannesjo Apr 3, 2025
7b75b9d
feat(timeTracking): outline updating both archives
johannesjo Apr 3, 2025
62943a6
feat(timeTracking): make also task archive stuff work in a smart and …
johannesjo Apr 3, 2025
ce5f7f6
feat(timeTracking): rename archive to archiveYoung
johannesjo Apr 3, 2025
dd16cd8
feat(timeTracking): replace taskArchive everywhere
johannesjo Apr 4, 2025
1ae7d1b
feat(timeTracking): implement flushing mechanism 1
johannesjo Apr 4, 2025
4fb5f9c
feat(timeTracking): implement flushing mechanism 2
johannesjo Apr 4, 2025
79eb8fa
test(timeTracking): make them work again
johannesjo Apr 4, 2025
6e3eb9a
feat(timeTracking): eliminate quirks for sort data to flush functions
johannesjo Apr 4, 2025
2cf6ee7
feat(timeTracking): add cleanup for timeTracking data on project or t…
johannesjo Apr 4, 2025
ae777b5
feat(timeTracking): flush parent and child tasks always together to o…
johannesjo Apr 4, 2025
82e01d6
feat(timeTracking): also migrate legacy tasks without doneOn
johannesjo Apr 4, 2025
b917ca0
feat(timeTracking): improve code
johannesjo Apr 4, 2025
f30718d
feat(timeTracking): make project and tag related data deletion work
johannesjo Apr 4, 2025
514aea1
feat(timeTracking): make getBreakNrForProject$ and getBreakTimeForPro…
johannesjo Apr 4, 2025
2267d1d
test(timeTracking): add unit test for merge-time-tracking-states.spec.ts
johannesjo Apr 4, 2025
5fc9281
test(timeTracking): add for time tracking reducer
johannesjo Apr 4, 2025
c7439c6
feat(timeTracking): adjust flushing logic once more
johannesjo Apr 4, 2025
b2b52fa
feat(timeTracking): add vals for testing
johannesjo Apr 4, 2025
fd6d389
feat(timeTracking): be a bit more lenient for data repair script
johannesjo Apr 5, 2025
15898f8
feat(timeTracking): improve initial migration behavior
johannesjo Apr 5, 2025
6a78049
feat(pfapi): also filter out modelIds without a local model ctrl
johannesjo Apr 5, 2025
3e29554
feat(pfapi): improve typing
johannesjo Apr 5, 2025
10fbc71
feat(timeTracking): make archive update trigger work as expected
johannesjo Apr 5, 2025
5cb0858
feat(timeTracking): improve model
johannesjo Apr 5, 2025
6890a52
feat(timeTracking): avoid empty object creation
johannesjo Apr 5, 2025
bd1c692
feat(pfapi): implement validation and repair
johannesjo Apr 6, 2025
a9e722a
feat(pfapi): improve on validations
johannesjo Apr 6, 2025
1e88740
feat(pfapi): add some validations
johannesjo Apr 6, 2025
70ff1eb
feat(pfapi): just delete stray backup if not restored
johannesjo Apr 9, 2025
3d132f1
feat(pfapi): make most basic validations via typia work
johannesjo Apr 9, 2025
40cd575
feat(pfapi): add task model validation and proper migration
johannesjo Apr 9, 2025
464b854
feat(pfapi): cleanup logs
johannesjo Apr 9, 2025
84238dd
test(pfapi): make em run again
johannesjo Apr 9, 2025
809893b
feat(pfapi): remove ui property on archiving
johannesjo Apr 9, 2025
1cd68e5
feat(pfapi): add validations for all the models
johannesjo Apr 9, 2025
c6f03b6
feat(pfapi): prevent endless loop during backup import
johannesjo Apr 9, 2025
5d1dc92
feat(pfapi): add defaults to board during migration
johannesjo Apr 10, 2025
5e79c81
feat(pfapi): adjust sound model to reality
johannesjo Apr 10, 2025
385a1e2
feat(pfapi): add validate all data and legacy data cases work
johannesjo Apr 10, 2025
da8181d
build: ignore compiled environment files
johannesjo Apr 10, 2025
8d83598
feat(pfapi): add note for later
johannesjo Apr 10, 2025
fb3a381
feat(task): improve ShowSubTasksMode model by renaming it and reducin…
johannesjo Apr 10, 2025
c959250
feat(task): also cleanup empty notes
johannesjo Apr 10, 2025
95567c2
feat(pfapi): re-structure validation fns
johannesjo Apr 10, 2025
cc778f8
feat(pfapi): make data repair stuff work better
johannesjo Apr 10, 2025
eb74e3c
fix: don't update daily summary note until really changed
johannesjo Apr 10, 2025
8686879
feat(pfapi): improve structure for validation stuff
johannesjo Apr 10, 2025
1c6a428
feat(pfapi): remove direct bindings from pfapi service in favor of di…
johannesjo Apr 10, 2025
dae2f3d
feat(pfapi): improve validity check message
johannesjo Apr 10, 2025
e3d9a14
fix(task): wrong model
johannesjo Apr 10, 2025
df67f4a
feat: sync whenever app goes to background on mobile
johannesjo Apr 10, 2025
43ee2a7
build: add stats command
johannesjo Apr 10, 2025
657340d
refactor(pfapi): cleanup fns
johannesjo Apr 11, 2025
3e8b55f
refactor(pfapi): improve on database functions
johannesjo Apr 11, 2025
15180e7
refactor(pfapi): improve migration service
johannesjo Apr 11, 2025
7dd76ee
refactor(pfapi): improve meta model ctrl
johannesjo Apr 11, 2025
a651555
refactor(pfapi): use 0 as pfLog error code
johannesjo Apr 11, 2025
45ad1d8
refactor(pfapi): improve model-ctrl
johannesjo Apr 11, 2025
cd16206
refactor(pfapi): improve sync-provider-private-cfg-store
johannesjo Apr 11, 2025
472f918
refactor(pfapi): improve sync.service
johannesjo Apr 11, 2025
9990da6
refactor(pfapi): improve sync.service.spec
johannesjo Apr 11, 2025
5f896c9
feat(pfapi): implement deletion of obsolete data during sync
johannesjo Apr 11, 2025
f529ed0
refactor(pfapi): improve meta-sync.service.ts
johannesjo Apr 11, 2025
740da32
refactor(pfapi): improve dropbox-api stuff
johannesjo Apr 11, 2025
5c2e821
refactor(pfapi): improve file sync stuff
johannesjo Apr 11, 2025
489bc14
refactor(pfapi): improve webdav stuff
johannesjo Apr 11, 2025
3fc6f80
fix(pfapi): error when adding sub task
johannesjo Apr 11, 2025
9844b21
fix: various quirks for new validation
johannesjo Apr 11, 2025
d2ece8a
refactor: remove legacy stuff
johannesjo Apr 11, 2025
59e67e7
fix: legacy data edge case with motivationalImgs
johannesjo Apr 11, 2025
4ee9c9f
build: update deps 1
johannesjo Apr 12, 2025
c37849b
build: update package-lock.json
johannesjo Apr 14, 2025
2b430d8
feat(pfapi): make decryption work and ask for password if wrong
johannesjo Apr 14, 2025
1e12417
feat(pfapi): make decryption work and ask for password if wrong
johannesjo Apr 14, 2025
4807bc7
feat(pfapi): improve private config interface
johannesjo Apr 14, 2025
3141be4
feat(pfapi): save encryption key privately
johannesjo Apr 14, 2025
7649288
feat(pfapi): save encryption key privately 2
johannesjo Apr 14, 2025
992c1f1
feat(pfapi): make decryption wrong password cases work smoothly
johannesjo Apr 14, 2025
4e0940f
feat(pfapi): improve migration and avoid potential error cases
johannesjo Apr 14, 2025
6109d43
refactor(pfapi): improve migration and avoid potential error cases
johannesjo Apr 14, 2025
5bf22e5
feat(pfapi): improve sync service and fix tests
johannesjo Apr 14, 2025
69e1062
feat(pfapi): remove testing thresholds for archive flush
johannesjo Apr 14, 2025
230e8de
feat(pfapi): improve dropbox
johannesjo Apr 14, 2025
4bc0626
feat(pfapi): work around edge case
johannesjo Apr 14, 2025
2a0566a
feat(pfapi): get etag directly from upload
johannesjo Apr 14, 2025
647e022
feat(pfapi): add various translations
johannesjo Apr 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ electron-builder.win-store.yaml

# ignore changes
./src/environments/versions.ts
/src/environments/environment.js
/src/environments/environment.js.map
3 changes: 2 additions & 1 deletion android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ android {
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
implementation project(':capacitor-app')

implementation project(':capacitor-filesystem')
implementation project(':capawesome-capacitor-background-task')
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,33 @@ class JavaScriptInterface(
return sb
}

@JavascriptInterface
fun removeFile(filePath: String) {
Log.d("SuperProductivity", "removeFile: trying to remove filePath: $filePath")
// Get folder path
val sp = activity.getPreferences(Context.MODE_PRIVATE)
val folderPath = sp.getString("filesyncFolder", "") ?: ""

// Scoped storage permission management for Android 10+, but also works for Android < 10
// Open file with write access, using DocumentFile URI
val folder = DocumentFile.fromTreeUri(activity, Uri.parse(folderPath))
val file = folder?.findFile(filePath)
Log.d("SuperProductivity", "removeFile: trying to remove: $file")

if (file != null && file.exists()) {
// File exists, attempt to delete it
val deleted = file.delete()

if (deleted) {
Log.d("SuperProductivity", "File deleted successfully: $filePath")
} else {
Log.e("SuperProductivity", "Failed to delete the file: $filePath")
}
} else {
Log.d("SuperProductivity", "File does not exist: $filePath")
}
}

@Suppress("unused")
@JavascriptInterface
fun writeFile(filePath: String, data: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import java.io.ByteArrayInputStream
* Strip the original WebViewClient logic to ensure that both types share the same logic
*/
class WebViewRequestHandler(private val activity: Activity, private val serviceHost: String) {
private val CORS_SKIP_HEADER = "sp_cors_skip"

@Deprecated("Deprecated in Java")
fun handleUrlLoading(view: WebView, url: String): Boolean {
Expand All @@ -36,11 +37,17 @@ class WebViewRequestHandler(private val activity: Activity, private val serviceH


fun interceptWebRequest(request: WebResourceRequest?): WebResourceResponse? {

try {
if (request == null || request.isForMainFrame) {
return null
}

if (!request.requestHeaders.containsKey(CORS_SKIP_HEADER)) {
Log.v("TW", "_______________________________________")
return null
}

if (request.url?.path?.contains("assets/icons/favicon") == true) {
try {
return WebResourceResponse("image/png", null, null)
Expand All @@ -64,14 +71,15 @@ class WebViewRequestHandler(private val activity: Activity, private val serviceH
return null
}


val client = OkHttpClient()
val newRequestBuilder = Request.Builder()
.url(request.url.toString())
.method(request.method, null)

for ((key, value) in request.requestHeaders) {
Log.v("TW", "interceptRequest header:${key} – ${value}")
if (key == "User-Agent" || key == "Origin" || key == "Referer" || key == "Sec-Fetch-Mode") {
if (key == CORS_SKIP_HEADER || key == "User-Agent" || key == "Origin" || key == "Referer" || key == "Sec-Fetch-Mode") {
continue
}
newRequestBuilder.addHeader(key, value)
Expand Down
6 changes: 6 additions & 0 deletions android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/

include ':capacitor-app'
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')

include ':capacitor-filesystem'
project(':capacitor-filesystem').projectDir = new File('../node_modules/@capacitor/filesystem/android')

include ':capawesome-capacitor-background-task'
project(':capawesome-capacitor-background-task').projectDir = new File('../node_modules/@capawesome/capacitor-background-task/android')
5 changes: 5 additions & 0 deletions capacitor.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ const config: CapacitorConfig = {
appId: 'com.superproductivity.superproductivity',
appName: 'super-productivity',
webDir: 'dist/browser',
plugins: {
CapacitorHttp: {
enabled: true,
},
},
};

export default config;
4 changes: 2 additions & 2 deletions electron/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IPC } from './shared-with-frontend/ipc-events.const';
import { LocalBackupMeta } from '../src/app/imex/local-backup/local-backup.model';
import * as path from 'path';
import { error, log } from 'electron-log/main';
import { AppDataComplete } from '../src/app/imex/sync/sync.model';
import { AppDataCompleteLegacy } from '../src/app/imex/sync/sync.model';

export const BACKUP_DIR = path.join(app.getPath('userData'), `backups`);

Expand Down Expand Up @@ -58,7 +58,7 @@ export function initBackupAdapter(): void {
}

// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
function backupData(ev: IpcMainEvent, data: AppDataComplete): void {
function backupData(ev: IpcMainEvent, data: AppDataCompleteLegacy): void {
if (!existsSync(BACKUP_DIR)) {
mkdirSync(BACKUP_DIR);
}
Expand Down
7 changes: 5 additions & 2 deletions electron/electronAPI.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import {
} from '../src/app/features/config/global-config.model';
import { KeyboardConfig } from '../src/app/features/config/keyboard-config.model';
import { JiraCfg } from '../src/app/features/issue/providers/jira/jira.model';
import { AppDataComplete, SyncGetRevResult } from '../src/app/imex/sync/sync.model';
import { AppDataCompleteLegacy, SyncGetRevResult } from '../src/app/imex/sync/sync.model';
import { Task } from '../src/app/features/tasks/task.model';
import { LocalBackupMeta } from '../src/app/imex/local-backup/local-backup.model';
import { AppDataCompleteNew } from '../src/app/pfapi/pfapi-config';

export interface ElectronAPI {
on(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): void;
Expand Down Expand Up @@ -38,6 +39,8 @@ export interface ElectronAPI {
localRev: string | null;
}): Promise<{ rev: string; dataStr: string | undefined } | Error>;

fileSyncRemove(args: { filePath: string }): Promise<unknown | Error>;

checkDirExists(args: { dirPath: string }): Promise<true | Error>;

pickDirectory(): Promise<string | undefined>;
Expand Down Expand Up @@ -106,7 +109,7 @@ export interface ElectronAPI {

jiraSetupImgHeaders(args: { jiraCfg: JiraCfg }): void;

backupAppData(appData: AppDataComplete): void;
backupAppData(appData: AppDataCompleteLegacy | AppDataCompleteNew): void;

updateCurrentTask(task: Task | null);

Expand Down
24 changes: 23 additions & 1 deletion electron/local-file-sync.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IPC } from './shared-with-frontend/ipc-events.const';
import { SyncGetRevResult } from '../src/app/imex/sync/sync.model';
import { readdirSync, readFileSync, statSync, writeFileSync } from 'fs';
import { readdirSync, readFileSync, statSync, writeFileSync, unlinkSync } from 'fs';
import { error, log } from 'electron-log/main';
import { dialog, ipcMain } from 'electron';
import { getWin } from './main-window';
Expand Down Expand Up @@ -92,6 +92,28 @@ export const initLocalFileSyncAdapter = (): void => {
},
);

ipcMain.handle(
IPC.FILE_SYNC_REMOVE,
(
ev,
{
filePath,
}: {
filePath: string;
},
): void | Error => {
try {
console.log(IPC.FILE_SYNC_REMOVE, filePath);
unlinkSync(filePath);
return;
} catch (e) {
log('ERR: Sync error while loading file from ' + filePath);
error(e);
return new Error(e as string);
Copy link
Preview

Copilot AI Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting the caught error to a string using 'e as string' may not reliably convert non-string errors. Consider using e.toString() to produce a consistent error message.

Suggested change
return new Error(e as string);
return new Error(e.toString());

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

}
},
);

ipcMain.handle(
IPC.CHECK_DIR_EXISTS,
(
Expand Down
1 change: 1 addition & 0 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const ea: ElectronAPI = {
rev: string;
dataStr: string | undefined;
}>,
fileSyncRemove: (filePath) => _invoke('FILE_SYNC_REMOVE', filePath) as Promise<void>,
checkDirExists: (dirPath) =>
_invoke('CHECK_DIR_EXISTS', dirPath) as Promise<true | Error>,

Expand Down
1 change: 1 addition & 0 deletions electron/shared-with-frontend/ipc-events.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export enum IPC {

FILE_SYNC_LOAD = 'FILE_SYNC_LOAD',
FILE_SYNC_SAVE = 'FILE_SYNC_SAVE',
FILE_SYNC_REMOVE = 'FILE_SYNC_REMOVE',
FILE_SYNC_GET_REV_AND_CLIENT_UPDATE = 'FILE_SYNC_GET_REV_AND_CLIENT_UPDATE',

CHECK_DIR_EXISTS = 'CHECK_DIR_EXISTS',
Expand Down
2 changes: 1 addition & 1 deletion electron/tsconfig.electron.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"resolveJsonModule": false,
"resolveJsonModule": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
Expand Down
Loading
Loading