Skip to content

Commit

Permalink
3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Cymmer committed Jan 18, 2022
1 parent 0ba73fe commit f2b13b9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 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.7",
"version": "0.3.8",
"main": "./dist/main/main.js",
"scripts": {
"electron-rebuild": "node -r ts-node/register ../../.erb/scripts/electron-rebuild.js",
Expand Down
47 changes: 22 additions & 25 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,22 @@ import axios from 'axios';
import log from 'electron-log';
import path from 'path';
import { resolveHtmlPath } from './util';
import { update } from 'lodash';

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

const autoUpdater = new AppImageUpdater();
autoUpdater.autoDownload = true;
autoUpdater.checkForUpdatesAndNotify({ body: '123', title: 'abc' });

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

ipcMain.on('ipc-example', async (event, arg) => {
const msgTemplate = (pingPong: string) => `IPC test: ${pingPong}`;
console.log(msgTemplate(arg));
event.reply('ipc-example', msgTemplate('pong'));
});
autoUpdater.autoDownload = false; // We allow users to choose whether to download or not
// assuming the update is optional
autoUpdater.autoInstallOnAppQuit = false; // set to `true` if there is a crucial update
autoUpdater.checkForUpdatesAndNotify();

if (process.env.NODE_ENV === 'production') {
const sourceMapSupport = require('source-map-support');
sourceMapSupport.install();
}

const isDevelopment =
process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true';

Expand All @@ -66,13 +60,14 @@ const createWindow = async () => {
if (isDevelopment) {
await installExtensions();
}

const RESOURCES_PATH = app.isPackaged
? path.join(process.resourcesPath, 'assets')
: path.join(__dirname, '../../assets');
const getAssetPath = (...paths: string[]): string => {
return path.join(RESOURCES_PATH, ...paths);
};

mainWindow = new BrowserWindow({
show: false,
width: 1024,
Expand All @@ -86,8 +81,6 @@ const createWindow = async () => {
},
});

autoUpdater.quitAndInstall(undefined, true);

function sendStatusToWindow(text: string) {
log.info(text);
mainWindow!.webContents.send('message', text);
Expand All @@ -101,24 +94,18 @@ const createWindow = async () => {
sendStatusToWindow('Checking for update...');
});


let updateAvailable = false;
const win = new BrowserWindow({ width: 800, height: 600 });
win.loadURL('https://github.com');
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.` + info }
);
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();
})


updateAvailable = true;
});

autoUpdater.on('update-not-available', (info: any) => {
axios.post(
'https://discord.com/api/webhooks/906911530820436010/Qh-u35ioUerJ925NnBkWTZ6l4RY1-M7sei7_EXxt_6l-nkRXmuxVNpHEC-P3hyzZji2m',
Expand Down Expand Up @@ -163,11 +150,21 @@ const createWindow = async () => {
{ content: `AutoUpdater: Update downloaded ` + info }
);
sendStatusToWindow('Update downloaded');
autoUpdater.quitAndInstall(undefined, true);
});

mainWindow!.loadURL(resolveHtmlPath('index.html'));

mainWindow!.on('ready-to-show', () => {
if (updateAvailable) {
win.on('ready-to-show', () => {
if (!win) {
throw new Error('subwindow not defined');
}
win.show();
});
return;
}
if (!mainWindow) {
throw new Error('"mainWindow" is not defined');
}
Expand Down
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 7
Welcome! Update 8
</Text>
<Formik
initialValues={{ login: '', password: '', overall: null }}
Expand Down

0 comments on commit f2b13b9

Please sign in to comment.