thamara / time-to-leave

Log work hours and get notified when it's time to leave the office and start to live.
http://timetoleave.app
GNU General Public License v3.0
463 stars 272 forks source link

Adapting calendar to use a non-remote environment #1018

Closed araujoarthur0 closed 1 year ago

araujoarthur0 commented 1 year ago

Related issue

Closes #889

Context / Background

Just like #887, this time for the calendar part. "In #646 we are trying to update electron to the newest version, but we're blocked because we're using electron remote, and that is deprecated in the newest versions."

What change is being introduced by this PR?

In this patch I adapt the Calendar window to work through a preload script, and an isolated environment, without any node module dependencies outside of what the preload API offers.

Basically, I exposed an API on the new files renderer/preload-scripts/calendar-api.js and calendar-bridge.js using the ContextBridge electron object (see https://www.electronjs.org/docs/latest/api/context-bridge). This API is defined via the main process, and is set to the global window object, and can be accessed in the calendar.js file, loaded in a BrowserWindow, inside a new renderer process.

How will this be tested?

Same as before. Manual tests also were executed.

codecov[bot] commented 1 year ago

Codecov Report

Merging #1018 (cc32c2a) into main (e25523f) will increase coverage by 4.25%. Report is 1 commits behind head on main. The diff coverage is 20.00%.

@@            Coverage Diff             @@
##             main    #1018      +/-   ##
==========================================
+ Coverage   75.04%   79.30%   +4.25%     
==========================================
  Files          26       21       -5     
  Lines        2188     1261     -927     
  Branches      345      188     -157     
==========================================
- Hits         1642     1000     -642     
+ Misses        546      261     -285     
Files Coverage Δ
js/time-balance.js 100.00% <ø> (ø)
js/main-window.js 73.50% <87.50%> (+0.46%) :arrow_up:
js/menus.js 81.73% <50.00%> (ø)
src/calendar.js 0.00% <0.00%> (ø)

... and 4 files with indirect coverage changes