-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_events.js
More file actions
37 lines (33 loc) · 1.63 KB
/
Copy pathfix_events.js
File metadata and controls
37 lines (33 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const fs = require('fs');
const path = require('path');
const dirs = [
__dirname,
path.join(__dirname, 'SignalLM-Android', 'app', 'src', 'main', 'assets')
];
for (const dir of dirs) {
// Fix settings.js saveSettings
const settingsJsPath = path.join(dir, 'settings.js');
if (fs.existsSync(settingsJsPath)) {
let content = fs.readFileSync(settingsJsPath, 'utf8');
if (!content.includes("window.dispatchEvent(new Event('settingsChanged'));")) {
content = content.replace(/localStorage\.setItem\(STORAGE_KEYS\.settings, JSON\.stringify\(settings\)\);/g, "localStorage.setItem(STORAGE_KEYS.settings, JSON.stringify(settings));\n window.dispatchEvent(new Event('settingsChanged'));");
fs.writeFileSync(settingsJsPath, content, 'utf8');
}
}
// Fix mcp.js saveSettings
const mcpJsPath = path.join(dir, 'mcp.js');
if (fs.existsSync(mcpJsPath)) {
let content = fs.readFileSync(mcpJsPath, 'utf8');
if (!content.includes("window.dispatchEvent(new Event('settingsChanged'));")) {
content = content.replace(/localStorage\.setItem\(STORAGE_KEYS\.settings, JSON\.stringify\(settings\)\);/g, "localStorage.setItem(STORAGE_KEYS.settings, JSON.stringify(settings));\n window.dispatchEvent(new Event('settingsChanged'));");
fs.writeFileSync(mcpJsPath, content, 'utf8');
}
}
// Fix index.js listener
const indexJsPath = path.join(dir, 'index.js');
if (fs.existsSync(indexJsPath)) {
let content = fs.readFileSync(indexJsPath, 'utf8');
content = content.replace(/loadWorkspaceContext\(\);/g, "hydrateFileContext(); loadWorkspaceHandle();");
fs.writeFileSync(indexJsPath, content, 'utf8');
}
}