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

session-stores/cookie: Convert private volatile properties to methods #1886

Merged
merged 1 commit into from
Jul 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions addon/session-stores/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,22 @@ export default BaseStore.extend({
return owner && owner.lookup('service:fastboot');
}),

_secureCookies: computed(function() {
_secureCookies() {
if (this.get('_fastboot.isFastBoot')) {
return this.get('_fastboot.request.protocol') === 'https';
}

return window.location.protocol === 'https:';
}).volatile(),
},

_isPageVisible: computed(function() {
_isPageVisible() {
if (this.get('_fastboot.isFastBoot')) {
return false;
} else {
const visibilityState = typeof document !== 'undefined' ? document.visibilityState || 'visible' : false;
return visibilityState === 'visible';
}
}).volatile(),
},

init() {
this._super(...arguments);
Expand Down Expand Up @@ -237,7 +237,7 @@ export default BaseStore.extend({
domain: this.get('cookieDomain'),
expires: isEmpty(expiration) ? null : new Date(expiration),
path: this.get('cookiePath'),
secure: this.get('_secureCookies')
secure: this._secureCookies()
};
if (this._oldCookieName) {
A([this._oldCookieName, `${this._oldCookieName}-expiration_time`]).forEach((oldCookie) => {
Expand Down Expand Up @@ -281,7 +281,7 @@ export default BaseStore.extend({
cancel(this._renewExpirationTimeout);
this._renewExpirationTimeout = later(this, this._renewExpiration, 60000);
}
if (this.get('_isPageVisible')) {
if (this._isPageVisible()) {
return this._renew();
} else {
return RSVP.resolve();
Expand Down