mirror of
				https://github.com/notion-enhancer/notion-enhancer.git
				synced 2025-11-04 16:18:08 +11:00 
			
		
		
		
	change window title to match page name instead of just 'Notion Desktop'
This commit is contained in:
		
							parent
							
								
									3493bfac24
								
							
						
					
					
						commit
						45bc46aae4
					
				@ -9,6 +9,7 @@
 | 
				
			|||||||
const url = require('url'),
 | 
					const url = require('url'),
 | 
				
			||||||
  path = require('path'),
 | 
					  path = require('path'),
 | 
				
			||||||
  electron = require('electron'),
 | 
					  electron = require('electron'),
 | 
				
			||||||
 | 
					  browserWindow = electron.remote.getCurrentWindow(),
 | 
				
			||||||
  { __notion } = require('../../pkg/helpers.js'),
 | 
					  { __notion } = require('../../pkg/helpers.js'),
 | 
				
			||||||
  config = require(`${__notion}/app/config.js`),
 | 
					  config = require(`${__notion}/app/config.js`),
 | 
				
			||||||
  constants = require(`${__notion}/app/shared/constants.js`),
 | 
					  constants = require(`${__notion}/app/shared/constants.js`),
 | 
				
			||||||
@ -218,6 +219,11 @@ module.exports = (store, __exports) => {
 | 
				
			|||||||
        ) {
 | 
					        ) {
 | 
				
			||||||
          this.views.tabs[event.target.id].children[0].innerText =
 | 
					          this.views.tabs[event.target.id].children[0].innerText =
 | 
				
			||||||
            event.args[0];
 | 
					            event.args[0];
 | 
				
			||||||
 | 
					          if (
 | 
				
			||||||
 | 
					            event.target.id == this.views.current.id &&
 | 
				
			||||||
 | 
					            browserWindow.getTitle() !== event.args[0]
 | 
				
			||||||
 | 
					          )
 | 
				
			||||||
 | 
					            browserWindow.setTitle(event.args[0]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      startSearch(isPeekView) {
 | 
					      startSearch(isPeekView) {
 | 
				
			||||||
@ -420,41 +426,25 @@ module.exports = (store, __exports) => {
 | 
				
			|||||||
                this.setState({ zoomFactor });
 | 
					                this.setState({ zoomFactor });
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
            let electronWindow;
 | 
					 | 
				
			||||||
            try {
 | 
					 | 
				
			||||||
              electronWindow = electron.remote.getCurrentWindow();
 | 
					 | 
				
			||||||
            } catch (error) {
 | 
					 | 
				
			||||||
              notionIpc.sendToMain('notion:log-error', {
 | 
					 | 
				
			||||||
                level: 'error',
 | 
					 | 
				
			||||||
                from: 'index',
 | 
					 | 
				
			||||||
                type: 'GetCurrentWindowError',
 | 
					 | 
				
			||||||
                error: error.message,
 | 
					 | 
				
			||||||
              });
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (!electronWindow) {
 | 
					 | 
				
			||||||
              this.setState({ error: true });
 | 
					 | 
				
			||||||
              this.handleReload();
 | 
					 | 
				
			||||||
              return;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            const sendFullScreenChangeEvent = () => {
 | 
					            const sendFullScreenChangeEvent = () => {
 | 
				
			||||||
              notionIpc.sendIndexToNotion(
 | 
					              notionIpc.sendIndexToNotion(
 | 
				
			||||||
                $notion,
 | 
					                $notion,
 | 
				
			||||||
                'notion:full-screen-changed'
 | 
					                'notion:full-screen-changed'
 | 
				
			||||||
              );
 | 
					              );
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            electronWindow.addListener(
 | 
					            browserWindow.addListener(
 | 
				
			||||||
              'enter-full-screen',
 | 
					              'enter-full-screen',
 | 
				
			||||||
              sendFullScreenChangeEvent
 | 
					              sendFullScreenChangeEvent
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
            electronWindow.addListener(
 | 
					            browserWindow.addListener(
 | 
				
			||||||
              'leave-full-screen',
 | 
					              'leave-full-screen',
 | 
				
			||||||
              sendFullScreenChangeEvent
 | 
					              sendFullScreenChangeEvent
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
            electronWindow.addListener(
 | 
					            browserWindow.addListener(
 | 
				
			||||||
              'enter-html-full-screen',
 | 
					              'enter-html-full-screen',
 | 
				
			||||||
              sendFullScreenChangeEvent
 | 
					              sendFullScreenChangeEvent
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
            electronWindow.addListener(
 | 
					            browserWindow.addListener(
 | 
				
			||||||
              'leave-html-full-screen',
 | 
					              'leave-html-full-screen',
 | 
				
			||||||
              sendFullScreenChangeEvent
 | 
					              sendFullScreenChangeEvent
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user