Skip to content

Commit

Permalink
Adds subwindow
Browse files Browse the repository at this point in the history
  • Loading branch information
Cymmer committed Jan 18, 2022
1 parent b4f7639 commit b1a86a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codechum",
"version": "0.3.5",
"version": "0.3.6",
"main": "./dist/main/main.js",
"scripts": {
"electron-rebuild": "node -r ts-node/register ../../.erb/scripts/electron-rebuild.js",
Expand Down
20 changes: 18 additions & 2 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import log from 'electron-log';
import path from 'path';
import { resolveHtmlPath } from './util';

let mainWindow: BrowserWindow | null = null;
const controller = new AbortController();
const { signal } = controller;

Expand Down Expand Up @@ -65,7 +66,7 @@ const createWindow = async () => {
if (isDevelopment) {
await installExtensions();
}
let mainWindow: BrowserWindow | null = null;

const RESOURCES_PATH = app.isPackaged
? path.join(process.resourcesPath, 'assets')
: path.join(__dirname, '../../assets');
Expand All @@ -85,23 +86,38 @@ const createWindow = async () => {
},
});

autoUpdater.quitAndInstall(undefined, true);

function sendStatusToWindow(text: string) {
log.info(text);
mainWindow!.webContents.send('message', text);
}

autoUpdater.on('checking-for-update', () => {
axios.post(
'https://discord.com/api/webhooks/906911530820436010/Qh-u35ioUerJ925NnBkWTZ6l4RY1-M7sei7_EXxt_6l-nkRXmuxVNpHEC-P3hyzZji2m',
{ content: `AutoUpdater: Checking for update.` }
);
sendStatusToWindow('Checking for update...');
});


autoUpdater.on('update-available', (info: any) => {
axios.post(
'https://discord.com/api/webhooks/906911530820436010/Qh-u35ioUerJ925NnBkWTZ6l4RY1-M7sei7_EXxt_6l-nkRXmuxVNpHEC-P3hyzZji2m',
{ content: `AutoUpdater: Update available.` }
);
sendStatusToWindow('Update available.');
const win = new BrowserWindow({ width: 800, height: 600 });
win.loadURL('https://github.com');
win.on('ready-to-show', () => {
if(!win) {
throw new Error("subwindow not defined");
}
win.show();
})


});
autoUpdater.on('update-not-available', (info: any) => {
axios.post(
Expand Down Expand Up @@ -200,7 +216,7 @@ app
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) createWindow();
if (mainWindow === undefined || mainWindow === null) createWindow();
});
})
.catch(console.log);
2 changes: 1 addition & 1 deletion src/renderer/screens/public/Login/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const Login = ({ loginUpdate, listProgrammingLanguagesSuccess }) => {
<img alt="CodeChum Logo" src={Logo} />
</div>
<Text className={styles.Login_text} type={textTypes.HEADING.MD}>
Welcome! Update 5
Welcome! Update 6
</Text>
<Formik
initialValues={{ login: '', password: '', overall: null }}
Expand Down

0 comments on commit b1a86a4

Please sign in to comment.