🌻 Lingua Libre SignIt web-browser extension translates selected word in French Sign Language via an elegant pop up so you learn sign language while reading online.
b9cf4f - Made a function to pass messages in order to adhere to DRY principle. Allows reusability while not cluttering the codebase and optimizes the message passing process.
6505f6 - Refactored the way SignItCoreContent.js received banana such that it is universal to both Chrome and FF.
557293 - Initialized modal every time when signit.hintIcon message was passed rather than calling it only when popup was undefined.
Description
I'll start with the 2nd change since first change is self explanatory.
Issue: Earlier I was type checking the browser using conditionals for the desired changes and that was also because , when arguments were passed in the SignItCoreContent() constructor function , it received banana's sourceMap as an instance of Map in Firefox and as Object in Chrome.
While this worked it passed unnecessary messages in background-script.js and made for an undesirable code overall.
Solution: I stored the sourceMap inside browser.storage.local and later passed it as argument whenever constructor function was in use. This is compatible with both Chrome and Firefox and I think it overall makes for a better code.
3rd change is a potential fix for challenges faced after #71
Issue: After passing messages from popup.js to both sw.js and background-script,js to execute functions (because we cant use backgroundPage as API namespace in MV3 unlike FF), the way UI language was being updated is buggy.
Firefox - In FF Popup UI updates immediately but for the changes to reflect in Modal whole web page has to be reloaded
Chrome - In Chrome Popup UI updates after it is toggled OFF then ON again , and same has to be done as FF to see changes in modal
Solution: Whenever signit.hintIcon is executed (modal is activated) initModalUI function is called every time unlike earlier when it is called only when popup === undefined. While this is a temporary fix since things were somehow working fine before previous PR. By doing this at least page does not need to be reloaded.
Changes
SignItCoreContent.js
receivedbanana
such that it is universal to both Chrome and FF.signit.hintIcon
message was passed rather than calling it only when popup was undefined.Description
I'll start with the 2nd change since first change is self explanatory.
Issue: Earlier I was type checking the browser using conditionals for the desired changes and that was also because , when arguments were passed in the
SignItCoreContent()
constructor function , it receivedbanana
'ssourceMap
as an instance ofMap
in Firefox and asObject
in Chrome.While this worked it passed unnecessary messages in
background-script.js
and made for an undesirable code overall.Solution: I stored the
sourceMap
insidebrowser.storage.local
and later passed it as argument whenever constructor function was in use. This is compatible with both Chrome and Firefox and I think it overall makes for a better code.3rd change is a potential fix for challenges faced after #71
Issue: After passing messages from
popup.js
to bothsw.js
andbackground-script,js
to execute functions (because we cant usebackgroundPage
as API namespace in MV3 unlike FF), the way UI language was being updated is buggy.Solution: Whenever
signit.hintIcon
is executed (modal is activated)initModalUI
function is called every time unlike earlier when it is called only whenpopup === undefined
. While this is a temporary fix since things were somehow working fine before previous PR. By doing this at least page does not need to be reloaded.