Project

General

Profile

« Previous | Next » 

Revision 4c6a2323

Added by koszko over 1 year ago

make Haketilo buildable again (for Mozilla)

How cool it is to throw away 5755 lines of code...

View differences:

background/patterns_query_manager.js
64 64
let script_update_occuring = false;
65 65
let script_update_needed;
66 66

  
67
async function update_content_script()
68
{
67
async function update_content_script() {
69 68
    if (script_update_occuring)
70 69
	return;
71 70

  
......
98 97
}
99 98
#ENDIF
100 99

  
101
function register(kind, object)
102
{
100
function register(kind, object) {
103 101
    if (kind === "mappings") {
104 102
	for (const [pattern, resource] of Object.entries(object.payloads))
105 103
	    pqt.register(tree, pattern, object.identifier, resource);
......
118 116
#ENDIF
119 117
}
120 118

  
121
function changed(kind, change)
122
{
119
function changed(kind, change) {
123 120
    const old_version = currently_registered.get(change.key);
124 121
    if (old_version !== undefined) {
125 122
	if (kind === "mappings") {
......
143 140
#ENDIF
144 141
}
145 142

  
146
async function start(secret_)
147
{
143
function setting_changed(change) {
144
    if (change.key !== "default_allow")
145
	return;
146

  
147
    default_allow.value = (change.new_val || {}).value;
148

  
149
#IF MOZILLA || MV3
150
    script_update_needed = true;
151
    setTimeout(update_content_script, 0);
152
#ENDIF
153
}
154

  
155
async function start(secret_) {
148 156
    secret = secret_;
149 157

  
150 158
    const [mapping_tracking, initial_mappings] =
......
155 163
    initial_mappings.forEach(m => register("mappings", m));
156 164
    initial_blocking.forEach(b => register("blocking", b));
157 165

  
158
    const set_allow_val = ch => default_allow.value = (ch.new_val || {}).value;
159 166
    const [setting_tracking, initial_settings] =
160
	  await haketilodb.track.settings(set_allow_val);
167
	  await haketilodb.track.settings(setting_changed);
168

  
161 169
    for (const setting of initial_settings) {
162 170
	if (setting.name === "default_allow")
163 171
	    Object.assign(default_allow, setting);

Also available in: Unified diff