Closed dlh2 closed 2 years ago
As suggested in this code in experiments.js
const staticHeaders = ['x-spam-status', 'x-spamd-result', 'x-spam-score', 'x-rspamd-score', 'x-spam-report']
const prefs = Services.prefs
const customDBHeaders = prefs.getCharPref('mailnews.customDBHeaders')
const customHeaders = prefs.getCharPref('mailnews.customHeaders')
let newCustomDBHeaders = customDBHeaders
let newCustomHeaders = customHeaders
for (const header of staticHeaders) {
if (customDBHeaders.indexOf(header) === -1) newCustomDBHeaders += ` ${header}`
if (customHeaders.indexOf(`${header}:`) === -1) newCustomHeaders += ` ${header}:`
}
for (const header of dynamicHeaders) {
if (customDBHeaders.indexOf(header) === -1) newCustomDBHeaders += ` ${header}`
if (customHeaders.indexOf(`${header}:`) === -1) newCustomHeaders += ` ${header}:`
}
prefs.getBranch('mailnews').setCharPref('.customDBHeaders', newCustomDBHeaders.trim())
prefs.getBranch('mailnews').setCharPref('.customHeaders', newCustomHeaders.trim())
There's no relevant code here, the idea behind it, is to save the headers in mailnews space, which should be used in another place, but there's no "mailnews" in another part of the project, therefore I'm going to delete this code.
From Added a way to log the experiments code 89dd827
As shown in https://github.com/thundernest/sample-extensions/tree/master/experiment
There's a way to see the data that is happening but is through an alert.
Also by the extended Firefox Documentation https://firefox-source-docs.mozilla.org/toolkit/components/extensions/webextensions/basics.html#globals-available-in-the-api-scripts-global
There's some globals that we don't need to import
Removing MailServices, it never appears on the project.
WebExtensionPolicy a thing that is global in our context, has the properties of extension.
From here it's going to be code optimization, I'm scared to do a optimization branch, when right now is +1,110 −216 (even if most of it is just for JSDoc.)
0109d85 For achieving storage.local.get as error, it's mostly when for some reason the I/O, cache, memory, is at its peakpoint, it could solve some problems in the future but I'd rather let the program crash itself
a32e759 We can check faster with double vertical bar, and I changed the rework function, because it made sense in some way but in this way it's more readable.
93a5b15 Okay this one is special.
I see that somehow we save at "win" the good boy SpamScore, but also we give to SpamScore the "win" part therefore:
win.SpamScore.win.SpamScore.win.Spamscore...win
Gradly compiler is quite smart and says a thing about it, but let's make it easier for it and divide the win with the things that we need.
Also, let's use correctly the class
https://archive.org is god
Now I'll get into "Thunderbird Good Practices"
In Thunderbird, all WebExtension API can be accessed through the browser. namespace, as with Firefox, but also through the messenger. namespace, which is a better fit for Thunderbird.
In the previous commit, we would reload the script everytime we changed Mail Folders, therefore we have an I/O delay (even if it's small), then reload all the resources then put in the "window" variable, therefore everytime we would load/unload the script.
Now we load the script in an "invented scope" instead of window, and everytime we need to apply the changes...
We'll just call it so it populates the column, then destroy the column when we swap folders.
Also in this way we remove "legacy code" which is supposed to be deprecated at some moment
Note: I feel that I don't need to Restart Thunderbird, neither Repair Folder
Question for @friedPotat0 : When is not mail:3pane? custom_score_column.js:186
At the moment, the only solution for not using "Components" is to create another addon as "Theme" as I can't combine the Addon with the Theme, in one extension.
Well well, I did it!
We really forgot about getImageSrc (after all it's legacy code and we don't even know how it worked), so we used it and we can now forget about the strange css selector injection.
Also made some optimizations on the way.
Note: seems that getImageSrc doesn't support SVG images
I'm scared of this warning:
Reading manifest: Warning processing web_accesible_resources: An unexpected property was found in the WebExtension manifest.
options.js had a general save for each modification, that way we atomize the operations
Sidenote:
Okay if I create a new profile the images and the score won't appear on column...
Probably because of this:
"Reading manifest: Warning processing web_accesible_resources: An unexpected property was found in the WebExtension manifest."
Yeah now working as expected.
Note: But we need to repair and restart
As said in #38, now the idea by far is to mutate the code from XPCom to WebExtensions.