experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

instant apply for slides

+48 -12
+3
TODO.md
··· 20 20 ## v? - Extensibility 21 21 22 22 Peek extensions 23 + - [ ] better name that "extension" 23 24 - [ ] figure out background app vs other 24 25 - [ ] maybe cmd stays in core? 25 26 - [ ] is background runtime aware? eg mobile/extension/desktop 26 27 - [ ] background app separation from "feature" apps, is runtime aware 27 28 - [ ] annotate all data with source creator/editor (sys vs extension) 29 + - [ ] figure out in-extension settings vs jamming in global settings 30 + - [ ] syncable settings (extension decides) 28 31 29 32 Web extensions 30 33 - [ ] WebExtension integration for priority only, on some platforms
+45 -12
app/slides/index.js
··· 13 13 // Map to track opened slides - key is slide key, value is window ID 14 14 const slideWindows = new Map(); 15 15 16 + // Track registered shortcuts for cleanup 17 + let registeredShortcuts = []; 18 + 16 19 const executeItem = (item) => { 17 20 const height = item.height || 600; 18 21 const width = item.width || 800; ··· 166 169 api.shortcuts.register(shortcut, () => { 167 170 executeItem(item); 168 171 }); 172 + 173 + registeredShortcuts.push(shortcut); 169 174 } 170 175 }); 171 176 }; 172 177 173 178 /** 174 - * Handle cleanup when the module is unloaded 179 + * Unregister all shortcuts and clean up windows 175 180 */ 176 - const cleanup = () => { 177 - console.log('Cleaning up slides module'); 178 - 181 + const uninit = () => { 182 + console.log('slides uninit - unregistering', registeredShortcuts.length, 'shortcuts'); 183 + 184 + // Unregister all shortcuts 185 + registeredShortcuts.forEach(shortcut => { 186 + api.shortcuts.unregister(shortcut); 187 + }); 188 + registeredShortcuts = []; 189 + 179 190 // Close or hide all slide windows 180 191 for (const [key, windowId] of slideWindows.entries()) { 181 192 console.log('Closing slide window:', key); 182 193 api.window.hide({ id: windowId }).catch(err => { 183 194 console.error('Error hiding slide window:', err); 184 - // Try to close it if hiding fails 185 195 api.window.close({ id: windowId }).catch(err => { 186 196 console.error('Error closing slide window:', err); 187 197 }); 188 198 }); 189 199 } 190 - 191 - // Clear the map 192 200 slideWindows.clear(); 193 201 }; 194 202 203 + /** 204 + * Reinitialize slides (called when settings change) 205 + * 206 + * TODO: This is inefficient - reinitializes all slides when any single 207 + * property changes. A better approach would be to diff the old and new 208 + * settings and only update the shortcuts that actually changed. 209 + */ 210 + const reinit = () => { 211 + console.log('slides reinit'); 212 + uninit(); 213 + 214 + const prefs = store.get(storageKeys.PREFS); 215 + const items = store.get(storageKeys.ITEMS); 216 + 217 + if (items && items.length > 0) { 218 + initItems(prefs, items); 219 + } 220 + }; 221 + 195 222 const init = () => { 196 - console.log('init'); 223 + console.log('slides init'); 197 224 198 225 const prefs = () => store.get(storageKeys.PREFS); 199 226 const items = () => store.get(storageKeys.ITEMS); ··· 209 236 } 210 237 }); 211 238 212 - // initialize slides 239 + // Initialize slides 213 240 if (items().length > 0) { 214 241 initItems(prefs(), items()); 215 242 } 216 - 243 + 244 + // Listen for settings changes to hot-reload 245 + api.subscribe('slides:settings-changed', () => { 246 + console.log('slides settings changed, reinitializing'); 247 + reinit(); 248 + }); 249 + 217 250 // Set up listener for app shutdown to clean up windows 218 - api.subscribe('app:shutdown', cleanup); 251 + api.subscribe('app:shutdown', uninit); 219 252 }; 220 253 221 254 export default { 222 255 defaults, 223 256 id, 224 257 init, 225 - cleanup, 258 + uninit, 226 259 labels, 227 260 schemas, 228 261 storageKeys