diff --git a/package.json b/package.json index 7e52cef40..11ca01556 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skye", - "version": "6.0.4-nightly.2", + "version": "6.0.4-nightly.3", "sideEffects": false, "description": "Extensible, fast and innovative web browser with material UI.", "keywords": [ diff --git a/src/main/index.ts b/src/main/index.ts index 34d9038d6..14e12e8d3 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -68,7 +68,7 @@ ipcMain.handle( return result; } } catch (e) { - console.log(e); + console.error(e); } }, ); diff --git a/src/main/menus/view.ts b/src/main/menus/view.ts index 46698ebc3..7bbcce18b 100644 --- a/src/main/menus/view.ts +++ b/src/main/menus/view.ts @@ -25,7 +25,7 @@ export const getViewMenu = ( appWindow.viewManager.create( { url: params.linkURL, - active: false, + active: true, }, true, ); @@ -55,7 +55,7 @@ export const getViewMenu = ( appWindow.viewManager.create( { url: params.srcURL, - active: false, + active: true, }, true, ); diff --git a/src/main/network/network-service-handler.ts b/src/main/network/network-service-handler.ts index afc45cb09..38eceaf3e 100644 --- a/src/main/network/network-service-handler.ts +++ b/src/main/network/network-service-handler.ts @@ -17,8 +17,8 @@ export class NetworkServiceHandler implements RpcMainHandler { request(e: RpcMainEvent, url: string) { try { return requestURL(url); - } catch (e) { - console.log(e); + } catch (err) { + console.error(err); return undefined; } } diff --git a/src/main/services/adblock.ts b/src/main/services/adblock.ts index 8cb98bbc7..471685998 100644 --- a/src/main/services/adblock.ts +++ b/src/main/services/adblock.ts @@ -30,7 +30,6 @@ let adblockRunning = false; let adblockInitialized = false; export const runAdblockService = async (ses: Electron.Session) => { - console.log(); if (!adblockInitialized) { adblockInitialized = true; await loadFilters(); diff --git a/src/main/services/storage.ts b/src/main/services/storage.ts index bf2ef4e2e..2bb72141f 100644 --- a/src/main/services/storage.ts +++ b/src/main/services/storage.ts @@ -463,8 +463,9 @@ export class StorageService { } else { return this.favicons.get(url); } - } catch (e) { - console.log(e); + } catch (err) { + console.error(err); + return undefined; } }; diff --git a/src/main/view-manager.ts b/src/main/view-manager.ts index 78570d89f..291fc6df7 100644 --- a/src/main/view-manager.ts +++ b/src/main/view-manager.ts @@ -166,11 +166,9 @@ export class ViewManager extends EventEmitter { public select(id: number, focus = true) { const { selected } = this; const view = this.views.get(id); - if (!view) { return; } - this.selectedId = id; if (selected) { diff --git a/src/main/view.ts b/src/main/view.ts index 0b1de8694..e45b4a1f9 100644 --- a/src/main/view.ts +++ b/src/main/view.ts @@ -195,7 +195,7 @@ export class View { this.window.viewManager.create({ url, active: true }, true); } else if (disposition === 'background-tab') { e.preventDefault(); - this.window.viewManager.create({ url, active: false }, true); + this.window.viewManager.create({ url, active: true }, true); } }, ); @@ -234,7 +234,7 @@ export class View { this.emitEvent('favicon-updated', fav); } catch (e) { this.favicon = ''; - // console.error(e); + console.error(e); } }, ); diff --git a/src/main/windows-service.ts b/src/main/windows-service.ts index 29fe15e06..a7f51f7ae 100644 --- a/src/main/windows-service.ts +++ b/src/main/windows-service.ts @@ -23,7 +23,12 @@ export class WindowsService { if (!win) throw new Error('Window not found'); const view = win.viewManager.create(details, false, false); - win.webContents.send('create-tab', { ...details }, false, view.id); + win.webContents.send( + 'create-tab', + { ...details, active: true }, + false, + view.id, + ); await new Promise((resolve) => { ipcMain.once('create-tab-reply-' + view.id, resolve); diff --git a/src/main/windows/app.ts b/src/main/windows/app.ts index acc783797..0663923d1 100644 --- a/src/main/windows/app.ts +++ b/src/main/windows/app.ts @@ -19,7 +19,7 @@ export class AppWindow { this.win = new BrowserWindow({ frame: false, minWidth: 900, - minHeight: 450, + minHeight: 250, width: 900, height: 700, titleBarStyle: 'hiddenInset', diff --git a/src/preloads/view-preload.ts b/src/preloads/view-preload.ts index fd34c81ba..ff67a3730 100644 --- a/src/preloads/view-preload.ts +++ b/src/preloads/view-preload.ts @@ -128,7 +128,6 @@ if ( contextBridge.exposeInMainWorld('process', process); contextBridge.exposeInMainWorld('settings', settings); contextBridge.exposeInMainWorld('require', (id: string) => { - console.log(id); if (id === 'electron') { return { ipcRenderer, app }; } diff --git a/src/renderer/views/app/components/AddressBar/index.tsx b/src/renderer/views/app/components/AddressBar/index.tsx index c5845c50f..53df3905a 100644 --- a/src/renderer/views/app/components/AddressBar/index.tsx +++ b/src/renderer/views/app/components/AddressBar/index.tsx @@ -82,7 +82,7 @@ const onKeyDown = (e: React.KeyboardEvent) => { ); return; } else if (isURL(value)) { - url = value.indexOf('://') === -1 ? `http://${value}` : value; + url = value.indexOf('://') === -1 ? `https://${value}` : value; } else { url = store.settings.searchEngine.url.replace('%s', value); } diff --git a/src/renderer/views/app/components/RightButtons/index.tsx b/src/renderer/views/app/components/RightButtons/index.tsx index b7a49d465..a98122145 100644 --- a/src/renderer/views/app/components/RightButtons/index.tsx +++ b/src/renderer/views/app/components/RightButtons/index.tsx @@ -18,8 +18,8 @@ import { AddTab } from '../Tabbar/style'; let menuRef: HTMLDivElement = null; -const onAddTabClick = () => { - store.tabs.addTab(); +const onAddTabClick = async () => { + await store.tabs.addTab(); }; const onDownloadsClick = async (e: React.MouseEvent) => { @@ -102,19 +102,12 @@ export const RightButtons = observer(() => { icon={ICON_MORE} size={18} /> - - - {/* (store.addTab.ref = r)} - /> */} ); }); diff --git a/src/renderer/views/app/components/Tab/index.tsx b/src/renderer/views/app/components/Tab/index.tsx index 74b06c10e..0b0349259 100644 --- a/src/renderer/views/app/components/Tab/index.tsx +++ b/src/renderer/views/app/components/Tab/index.tsx @@ -23,9 +23,11 @@ import store from '../../store'; import * as remote from '@electron/remote'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -const removeTab = (tab: ITab) => (e: React.MouseEvent) => { +const removeTab = (tab: ITab) => async ( + e: React.MouseEvent, +) => { e.stopPropagation(); - tab.close(); + await tab.close(); }; const toggleMuteTab = (tab: ITab) => (e: React.MouseEvent) => { @@ -64,9 +66,9 @@ const onMouseDown = (tab: ITab) => (e: React.MouseEvent) => { } }; -const onClick = (tab: ITab) => (e: React.MouseEvent) => { +const onClick = (tab: ITab) => async (e: React.MouseEvent) => { if (e.button === 4) { - tab.close(); + await tab.close(); return; } @@ -76,9 +78,11 @@ const onClick = (tab: ITab) => (e: React.MouseEvent) => { } }; -const onMouseUp = (tab: ITab) => (e: React.MouseEvent) => { +const onMouseUp = (tab: ITab) => async ( + e: React.MouseEvent, +) => { if (e.button === 1) { - tab.close(); + await tab.close(); } }; @@ -86,8 +90,8 @@ const onContextMenu = (tab: ITab) => () => { const menu = remote.Menu.buildFromTemplate([ { label: 'New tab to the right', - click: () => { - store.tabs.addTab( + click: async () => { + await store.tabs.addTab( { index: store.tabs.list.indexOf(store.tabs.selectedTab) + 1, }, @@ -116,14 +120,14 @@ const onContextMenu = (tab: ITab) => () => { { label: 'Reload', accelerator: 'CmdOrCtrl+R', - click: () => { - tab.callViewMethod('webContents.reload'); + click: async () => { + await tab.callViewMethod('webContents.reload'); }, }, { label: 'Duplicate', - click: () => { - store.tabs.addTab({ active: true, url: tab.url }); + click: async () => { + await store.tabs.addTab({ active: true, url: tab.url }); }, }, { @@ -144,37 +148,37 @@ const onContextMenu = (tab: ITab) => () => { { label: 'Close tab', accelerator: 'CmdOrCtrl+W', - click: () => { - tab.close(); + click: async () => { + await tab.close(); }, }, { label: 'Close other tabs', - click: () => { + click: async () => { for (const t of store.tabs.list) { if (t !== tab) { - t.close(); + await t.close(); } } }, }, { label: 'Close tabs to the left', - click: () => { + click: async () => { for (let i = store.tabs.list.indexOf(tab) - 1; i >= 0; i--) { - store.tabs.list[i].close(); + await store.tabs.list[i].close(); } }, }, { label: 'Close tabs to the right', - click: () => { + click: async () => { for ( let i = store.tabs.list.length - 1; i > store.tabs.list.indexOf(tab); i-- ) { - store.tabs.list[i].close(); + await store.tabs.list[i].close(); } }, }, diff --git a/src/renderer/views/app/models/tab.ts b/src/renderer/views/app/models/tab.ts index 0c382c162..d9eb56111 100644 --- a/src/renderer/views/app/models/tab.ts +++ b/src/renderer/views/app/models/tab.ts @@ -110,8 +110,8 @@ export class ITab { } if (active) { - requestAnimationFrame(() => { - this.select(); + requestAnimationFrame(async () => { + await this.select(); }); } @@ -247,7 +247,7 @@ export class ITab { } @action - public close() { + public async close() { store.tabs.closedUrl = this.url; store.tabs.canShowPreview = false; ipcRenderer.send(`hide-tab-preview-${store.windowId}`); @@ -291,10 +291,10 @@ export class ITab { !store.tabs.scrollable ) { const nextTab = store.tabs.list[index + 1]; - nextTab.select(); + await nextTab.select(); } else if (index - 1 >= 0 && !store.tabs.list[index - 1].isClosing) { const prevTab = store.tabs.list[index - 1]; - prevTab.select(); + await prevTab.select(); } } diff --git a/src/renderer/views/app/store/tabs.ts b/src/renderer/views/app/store/tabs.ts index 6f330871b..f7224a68d 100644 --- a/src/renderer/views/app/store/tabs.ts +++ b/src/renderer/views/app/store/tabs.ts @@ -88,43 +88,41 @@ export class TabsStore { const index = this.list.indexOf(this.selectedTab) + 1; options.index = index; } - this.createTab(options, id); - e.sender.send('create-tab-reply-' + id); - console.log('sent with id', id); }, ); - ipcRenderer.on('select-next-tab', () => { + ipcRenderer.on('select-next-tab', async () => { const i = this.list.indexOf(this.selectedTab); const nextTab = this.list[i + 1]; if (!nextTab) { if (this.list[0]) { - this.list[0].select(); + await this.list[0].select(); } } else { - nextTab.select(); + await nextTab.select(); } }); - ipcRenderer.on('select-tab-index', (e, i) => { - this.list[i]?.select(); + ipcRenderer.on('select-tab-index', async (e, i) => { + await this.list[i]?.select(); }); - ipcRenderer.on('select-tab-id', (e, id: number) => { - console.log('owo', id); - this.getTabById(id)?.select(); + ipcRenderer.on('select-tab-id', async (e, id: number) => { + const tab = this.getTabById(id); + + await tab?.select(); console.log(this.list.map((a) => [a.id, a.url])); - console.log(this.getTabById(id)); + console.log('huh', this.getTabById(id)); }); - ipcRenderer.on('select-last-tab', () => { - this.list[this.list.length - 1]?.select(); + ipcRenderer.on('select-last-tab', async () => { + await this.list[this.list.length - 1]?.select(); }); - ipcRenderer.on('select-previous-tab', () => { + ipcRenderer.on('select-previous-tab', async () => { const i = this.list.indexOf(this.selectedTab); const prevTab = this.list[i - 1]; @@ -133,12 +131,12 @@ export class TabsStore { this.list[this.list.length - 1].select(); } } else { - prevTab.select(); + await prevTab.select(); } }); - ipcRenderer.on('remove-tab', (e, id: number) => { - this.getTabById(id)?.close(); + ipcRenderer.on('remove-tab', async (e, id: number) => { + await this.getTabById(id)?.close(); }); ipcRenderer.on('tab-event', (e, event: TabEvent, tabId, args) => { @@ -174,8 +172,8 @@ export class TabsStore { } }); - ipcRenderer.on('revert-closed-tab', () => { - this.revertClosed(); + ipcRenderer.on('revert-closed-tab', async () => { + await this.revertClosed(); }); ipcRenderer.on('get-search-tabs', () => { @@ -219,7 +217,6 @@ export class TabsStore { this.removedTabs = 0; const tab = new ITab(options, id); - tab.tabGroupId = tabGroupId; if (options.index !== undefined) { @@ -638,7 +635,7 @@ export class TabsStore { } }; - public revertClosed() { - this.addTab({ active: true, url: this.closedUrl }); + public async revertClosed() { + await this.addTab({ active: true, url: this.closedUrl }); } } diff --git a/src/renderer/views/app/utils/view.ts b/src/renderer/views/app/utils/view.ts index e4fe37782..61b314d60 100644 --- a/src/renderer/views/app/utils/view.ts +++ b/src/renderer/views/app/utils/view.ts @@ -1,16 +1,16 @@ import store from '../store'; -export const loadURL = (url: string) => { +export const loadURL = async (url: string) => { const tab = store.tabs.selectedTab; if (!tab) { - store.tabs.addTab({ url, active: true }); + await store.tabs.addTab({ url, active: true }); } else { tab.url = url; try { - tab.callViewMethod('loadURL', url); - } catch (e) { - console.error(e); + await tab.callViewMethod('loadURL', url); + } catch (err) { + console.error(err); } } }; diff --git a/src/renderer/views/search/components/App/index.tsx b/src/renderer/views/search/components/App/index.tsx index 381dde219..fcf89fd83 100644 --- a/src/renderer/views/search/components/App/index.tsx +++ b/src/renderer/views/search/components/App/index.tsx @@ -30,7 +30,7 @@ const onKeyPress = (e: React.KeyboardEvent) => { if (suggestion.isSearch) { url = store.searchEngine.url.replace('%s', text); } else if (text.indexOf('://') === -1) { - url = `http://${text}`; + url = `https://${text}`; } } diff --git a/src/renderer/views/search/components/Suggestion/index.tsx b/src/renderer/views/search/components/Suggestion/index.tsx index 0f6c3a005..b1bd256c7 100644 --- a/src/renderer/views/search/components/Suggestion/index.tsx +++ b/src/renderer/views/search/components/Suggestion/index.tsx @@ -35,7 +35,7 @@ const onClick = (suggestion: ISuggestion) => () => { if (suggestion.isSearch) { url = store.searchEngine.url.replace('%s', url); } else if (url.indexOf('://') === -1) { - url = `http://${url}`; + url = `https://${url}`; } callViewMethod(store.tabId, 'loadURL', url); diff --git a/src/utils/url.ts b/src/utils/url.ts index d795ce893..d1c85633a 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -4,7 +4,7 @@ export const isURL = (input: string): boolean => { if (pattern.test(input)) { return true; } - return pattern.test(`http://${input}`); + return pattern.test(`https://${input}`); }; export const matchesPattern = (pattern: string, url: string) => { @@ -21,7 +21,7 @@ export const matchesPattern = (pattern: string, url: string) => { export const getDomain = (url: string): string => { let hostname = url; - if (hostname.includes('http://') || hostname.includes('https://')) { + if (hostname.includes('https://') || hostname.includes('https://')) { hostname = hostname.split('://')[1]; } @@ -40,5 +40,5 @@ export const getDomain = (url: string): string => { export const prefixHttp = (url: string): string => { url = url.trim(); - return url.includes('://') ? url : `http://${url}`; + return url.includes('://') ? url : `https://${url}`; };