Code Monkey home page Code Monkey logo

Comments (6)

megahertz avatar megahertz commented on June 16, 2024

Maybe update-available event is fired before a renderer process is in ready state. It seems that most of update logic is concentrated on a renderer side, so I can recommend you to move initialize code from the main process to a renderer.

from electron-simple-updater.

eduboxgithub avatar eduboxgithub commented on June 16, 2024

I will move my initial code to the render side and try it again.

But shouldn't the events fire every time I call the method checkForUpdates()?

from electron-simple-updater.

eduboxgithub avatar eduboxgithub commented on June 16, 2024

Ok, I removed the code from the index.js and created a service on the render side.

If I check the logs I see this messages:

[2019-07-24 19:33:19.139] [info] UpdateApp checking updates...
**[2019-07-24 19:33:19.203] [debug] Update for win32-x64-prod-v1.0.190 is not available** (this log was not made by me, I think it came from your code)
[2019-07-24 19:33:35.093] [info] CloseApp Admin Action
[2019-07-24 19:33:35.142] [info]  
[2019-07-24 19:33:35.142] [info] app 'will-quit'
[2019-07-24 19:33:35.142] [info]  
[2019-07-24 19:33:35.143] [info] StartExplorerProcess

But for exemple the event "update-not-available" was not dispatch, a least me function did not run:

private onUpdateNotAvailable()
{
	this.StatusUpdate = "There's no updates available.";
	this.Log("onUpdateNotAvailable");
}

from electron-simple-updater.

megahertz avatar megahertz commented on June 16, 2024

Could you try the code to make sure the problem is not in another place?

this.UpdaterElectron = this.ElectronService.remote.require('electron-simple-updater');
this.UpdaterElectron.on('update-not-available', () => console.log('NOT AVAILABLE');

from electron-simple-updater.

eduboxgithub avatar eduboxgithub commented on June 16, 2024

Hello @megahertz .

Oddly it worked... I changed my functions as you suggested and it's working.
I also added all the events on the remote side (index.js).

Then I had to request a manual update, because the code was executed out of Angular context and the changes were not detected.

Admin page on the render side

public Init()
{
        this.Log("this.UpdaterElectron.getFeedURL(): ", this.UpdaterElectron.getFeedURL());

	this.UpdaterElectron.on('update-not-available', () => 
	{
		this.SetStatus("Não existem novas versões.", false);

		this.Log("onUpdateNotAvailable message: ", this.StatusUpdate);
	});

	this.UpdaterElectron.on('update-available', (meta) => 
	{
		this.metaDataUpdate = meta;
	        this.SetStatus("Nova versão " + this.metaDataUpdate.version, false);
		this.Log("onUpdateAvailable message: ", this.StatusUpdate);
        });
}

public SetStatus(message:string, waitingResponse:boolean)
{
	this.IsCheckingUpdates = waitingResponse;
	this.StatusUpdate = message;

	**this.ChangeDetectorRef.detectChanges();**
}

Thank you for your time and support.

from electron-simple-updater.

megahertz avatar megahertz commented on June 16, 2024

Instead, you can just bind you methods like

this.UpdaterElectron.on('update-available', this.onUpdateAvailable.bind(this));

(but in this case off methods will not work if you'll uncomment it)
or bind methods in constructor, or use such as thing as https://github.com/andreypopp/autobind-decorator

from electron-simple-updater.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.