Skip to content

Commit 057db5a

Browse files
Kelly Seldenrwjblue
authored andcommitted
code cleanup on none location (#329)
* reuse config in computed * move TEMPORARY_REDIRECT_CODE to outside extend * use readOnly instead of reads, since we are not setting * use bool macro instead of manual * use let instead of const
1 parent bde3fef commit 057db5a

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

app/locations/none.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,36 @@ import Ember from 'ember';
22

33
const {
44
computed,
5-
computed: { reads },
5+
computed: { bool, readOnly },
66
inject: { service },
77
get,
88
getOwner
99
} = Ember;
1010

11+
const TEMPORARY_REDIRECT_CODE = 307;
12+
1113
export default Ember.NoneLocation.extend({
1214
implementation: 'fastboot',
1315
fastboot: service(),
1416

15-
_fastbootHeadersEnabled: computed(function () {
16-
const config = getOwner(this).resolveRegistration('config:environment');
17-
return !!get(config, 'fastboot.fastbootHeaders');
17+
_config: computed(function () {
18+
return getOwner(this).resolveRegistration('config:environment');
1819
}),
1920

21+
_fastbootHeadersEnabled: bool('_config.fastboot.fastbootHeaders'),
22+
2023
_redirectCode: computed(function () {
21-
const TEMPORARY_REDIRECT_CODE = 307;
22-
const config = getOwner(this).resolveRegistration('config:environment');
23-
return get(config, 'fastboot.redirectCode') || TEMPORARY_REDIRECT_CODE;
24+
return get(this, '_config.fastboot.redirectCode') || TEMPORARY_REDIRECT_CODE;
2425
}),
2526

26-
_response: reads('fastboot.response'),
27-
_request: reads('fastboot.request'),
27+
_response: readOnly('fastboot.response'),
28+
_request: readOnly('fastboot.request'),
2829

2930
setURL(path) {
3031
if (get(this, 'fastboot.isFastBoot')) {
31-
const currentPath = get(this, 'path');
32-
const isInitialPath = !currentPath || currentPath.length === 0;
33-
const isTransitioning = currentPath !== path;
32+
let currentPath = get(this, 'path');
33+
let isInitialPath = !currentPath || currentPath.length === 0;
34+
let isTransitioning = currentPath !== path;
3435
let response = get(this, '_response');
3536

3637
if (isTransitioning && !isInitialPath) {

0 commit comments

Comments
 (0)