Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract new version fetching and checking from the NewVersionNotifier component in a service #94

Merged

Conversation

pbernery
Copy link
Contributor

The logic is now in a service so that it can be used independently of the action.

There are slight behaviour changes and new behaviours as well.

The service contains an observable isNewVersionAvailable property. This property is set to true when a new version is available.

The version checking is slightly different: before, the first check was ignored because the component was comparing the previously fetched version and the latest fetched version. Now, the version is always checked against the version provided in environment.js. This thus means the comparison is always done against the compiled version of the app.

The component had a way to ignore a version, by setting the next version to check to the latest fetched version. To keep the compatibility with this behaviour, there is now an explicit list of "ignore versions" in the service, populated when the user closes the NewVersionNotifier. Note that this list is kept in memory only and when the user reloads the page, the list is empty again. This is the same behaviour as before.

I kept the code related to testing in the service to limit the changes, but this could be moved in the TestNewVersionService implementation so that the original NewVersionService is kept clean of testing behaviour.

The onNewVersion action still exists but is now in the service. If one needs this callback, he/she can overload the NewVersionService and override onNewVersion. Same thing for onError.

Some properties that were arguments of the component have been moved to the configuration.

… component in a service

The logic is now in a service so that it can be used independently of the action.

There are slight behaviour changes and new behaviours as well.

The service contains an observable `isNewVersionAvailable` property.
This property is set to true when a new version is available.

The version checking is slightly different: before, the first check was ignored because the component was comparing the previously fetched version and the latest fetched version.
Now, the version is always checked against the version provided in environment.js. This thus means the comparison is always done against the compiled version of the app.

The component had a way to ignore a version, by setting the next version to check to the latest fetched version. To keep the compatibility with this behaviour, there is now an explicit list of "ignore versions" in the service, populated when the user closes the `NewVersionNotifier`. Note that this list is kept in memory only and when the user reloads the page, the list is empty again. This is the same behaviour as before.

I kept the code related to testing in the service to limit the changes, but this could be moved in the TestNewVersionService implementation so that the original NewVersionService is kept clean of testing behaviour.

The onNewVersion action still exists but is now in the service. If one needs this callback, he/she can overload the NewVersionService and override onNewVersion. Same thing for onError.

Some properties that were arguments of the component have been moved to the configuration.
Some addon dependencies were declared in devDependencies while they are needed by the addon to run.
@knownasilya knownasilya merged commit cd131a0 into sethwebster:update-octane Jun 24, 2021
knownasilya pushed a commit that referenced this pull request Jun 28, 2021
…tifier component in a service (#94)

BREAKING CHANGE: introduces a new version service. Some arguments from the components have been moved here and other moved to the configuration.
BREAKING CHANGE: How the version check happens has also changed, see #94

* Enable JS code checking

* Extract new version fetching and checking from the NewVersionNotifier component in a service

The logic is now in a service so that it can be used independently of the action.

There are slight behaviour changes and new behaviours as well.

The service contains an observable `isNewVersionAvailable` property.
This property is set to true when a new version is available.

The version checking is slightly different: before, the first check was ignored because the component was comparing the previously fetched version and the latest fetched version.
Now, the version is always checked against the version provided in environment.js. This thus means the comparison is always done against the compiled version of the app.

The component had a way to ignore a version, by setting the next version to check to the latest fetched version. To keep the compatibility with this behaviour, there is now an explicit list of "ignore versions" in the service, populated when the user closes the `NewVersionNotifier`. Note that this list is kept in memory only and when the user reloads the page, the list is empty again. This is the same behaviour as before.

I kept the code related to testing in the service to limit the changes, but this could be moved in the TestNewVersionService implementation so that the original NewVersionService is kept clean of testing behaviour.

The onNewVersion action still exists but is now in the service. If one needs this callback, he/she can overload the NewVersionService and override onNewVersion. Same thing for onError.

Some properties that were arguments of the component have been moved to the configuration.

* Fix dependencies declaration

Some addon dependencies were declared in devDependencies while they are needed by the addon to run.
knownasilya added a commit that referenced this pull request Jun 29, 2021
* chore: prettier

* fix: update to glimmer component

BREAKING CHANGE: use GC for notifier

* fix: update waitFor

* fix: update deps

* feat: Extract new version fetching and checking from the NewVersionNotifier component in a service (#94)

BREAKING CHANGE: introduces a new version service. Some arguments from the components have been moved here and other moved to the configuration.
BREAKING CHANGE: How the version check happens has also changed, see #94

* Enable JS code checking

* Extract new version fetching and checking from the NewVersionNotifier component in a service

The logic is now in a service so that it can be used independently of the action.

There are slight behaviour changes and new behaviours as well.

The service contains an observable `isNewVersionAvailable` property.
This property is set to true when a new version is available.

The version checking is slightly different: before, the first check was ignored because the component was comparing the previously fetched version and the latest fetched version.
Now, the version is always checked against the version provided in environment.js. This thus means the comparison is always done against the compiled version of the app.

The component had a way to ignore a version, by setting the next version to check to the latest fetched version. To keep the compatibility with this behaviour, there is now an explicit list of "ignore versions" in the service, populated when the user closes the `NewVersionNotifier`. Note that this list is kept in memory only and when the user reloads the page, the list is empty again. This is the same behaviour as before.

I kept the code related to testing in the service to limit the changes, but this could be moved in the TestNewVersionService implementation so that the original NewVersionService is kept clean of testing behaviour.

The onNewVersion action still exists but is now in the service. If one needs this callback, he/she can overload the NewVersionService and override onNewVersion. Same thing for onError.

Some properties that were arguments of the component have been moved to the configuration.

* Fix dependencies declaration

Some addon dependencies were declared in devDependencies while they are needed by the addon to run.

* Make MAX_COUNT_IN_TESTING a configuration variable

This let tests override this option as needed.

* fix: keep the initial slash for fetching VERSION.txt

Before this commit, the fetch of VERSION.txt with a default configuration would result to calling "VERSION.txt", which means "fetch the file relative to the current page URL".

This may lead to issue in production, but leads to issues in some tests situation when using `ember test` where the full path to VERSION.txt is resolved to `/VERSION.txt` when declaring it in tests, while it is resolved to `http://localhost:7357/some-random-numbers/tests/VERSION.txt` when fetching the file.

This commit fixes the issue by not removing the `/` in front of VERSION.txt.

This fixes the isse for my scenarios; but I am not sure why there was this check and removal of the `/` in the first place, this thus may lead to breaking changes for some.

Co-authored-by: Ilya Radchenko <knownasilya@gmail.com>
knownasilya pushed a commit that referenced this pull request Nov 24, 2021
…tifier component in a service (#94)

BREAKING CHANGE: introduces a new version service. Some arguments from the components have been moved here and other moved to the configuration.
BREAKING CHANGE: How the version check happens has also changed, see #94

* Enable JS code checking

* Extract new version fetching and checking from the NewVersionNotifier component in a service

The logic is now in a service so that it can be used independently of the action.

There are slight behaviour changes and new behaviours as well.

The service contains an observable `isNewVersionAvailable` property.
This property is set to true when a new version is available.

The version checking is slightly different: before, the first check was ignored because the component was comparing the previously fetched version and the latest fetched version.
Now, the version is always checked against the version provided in environment.js. This thus means the comparison is always done against the compiled version of the app.

The component had a way to ignore a version, by setting the next version to check to the latest fetched version. To keep the compatibility with this behaviour, there is now an explicit list of "ignore versions" in the service, populated when the user closes the `NewVersionNotifier`. Note that this list is kept in memory only and when the user reloads the page, the list is empty again. This is the same behaviour as before.

I kept the code related to testing in the service to limit the changes, but this could be moved in the TestNewVersionService implementation so that the original NewVersionService is kept clean of testing behaviour.

The onNewVersion action still exists but is now in the service. If one needs this callback, he/she can overload the NewVersionService and override onNewVersion. Same thing for onError.

Some properties that were arguments of the component have been moved to the configuration.

* Fix dependencies declaration

Some addon dependencies were declared in devDependencies while they are needed by the addon to run.
knownasilya added a commit that referenced this pull request Nov 24, 2021
* chore: prettier

* fix: update to glimmer component

BREAKING CHANGE: use GC for notifier

* fix: update waitFor

* fix: update deps

* feat: Extract new version fetching and checking from the NewVersionNotifier component in a service (#94)

BREAKING CHANGE: introduces a new version service. Some arguments from the components have been moved here and other moved to the configuration.
BREAKING CHANGE: How the version check happens has also changed, see #94

* Enable JS code checking

* Extract new version fetching and checking from the NewVersionNotifier component in a service

The logic is now in a service so that it can be used independently of the action.

There are slight behaviour changes and new behaviours as well.

The service contains an observable `isNewVersionAvailable` property.
This property is set to true when a new version is available.

The version checking is slightly different: before, the first check was ignored because the component was comparing the previously fetched version and the latest fetched version.
Now, the version is always checked against the version provided in environment.js. This thus means the comparison is always done against the compiled version of the app.

The component had a way to ignore a version, by setting the next version to check to the latest fetched version. To keep the compatibility with this behaviour, there is now an explicit list of "ignore versions" in the service, populated when the user closes the `NewVersionNotifier`. Note that this list is kept in memory only and when the user reloads the page, the list is empty again. This is the same behaviour as before.

I kept the code related to testing in the service to limit the changes, but this could be moved in the TestNewVersionService implementation so that the original NewVersionService is kept clean of testing behaviour.

The onNewVersion action still exists but is now in the service. If one needs this callback, he/she can overload the NewVersionService and override onNewVersion. Same thing for onError.

Some properties that were arguments of the component have been moved to the configuration.

* Fix dependencies declaration

Some addon dependencies were declared in devDependencies while they are needed by the addon to run.

* Make MAX_COUNT_IN_TESTING a configuration variable

This let tests override this option as needed.

* fix: keep the initial slash for fetching VERSION.txt

Before this commit, the fetch of VERSION.txt with a default configuration would result to calling "VERSION.txt", which means "fetch the file relative to the current page URL".

This may lead to issue in production, but leads to issues in some tests situation when using `ember test` where the full path to VERSION.txt is resolved to `/VERSION.txt` when declaring it in tests, while it is resolved to `http://localhost:7357/some-random-numbers/tests/VERSION.txt` when fetching the file.

This commit fixes the issue by not removing the `/` in front of VERSION.txt.

This fixes the isse for my scenarios; but I am not sure why there was this check and removal of the `/` in the first place, this thus may lead to breaking changes for some.

Co-authored-by: Ilya Radchenko <knownasilya@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants