Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #457 from learn-co/beta-endpoint
Browse files Browse the repository at this point in the history
Create option to subscribe to bleeding updates
  • Loading branch information
drewprice authored May 12, 2017
2 parents 82737c6 + c9a015e commit 9299b7e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
37 changes: 26 additions & 11 deletions lib/learn-ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,32 @@ export default {
'learn-ide:clear-terminal': () => this.term.send(' ')
}));

atom.config.onDidChange(`${name}.terminalColors.basic`, () => colors.apply())

atom.config.onDidChange(`${name}.terminalColors.ansi`, () => colors.apply())

atom.config.onDidChange(`${name}.terminalColors.json`, ({newValue}) => {
colors.parseJSON(newValue);
});

atom.config.onDidChange(`${name}.notifier`, ({newValue}) => {
newValue ? this.activateNotifier() : this.notifier.deactivate()
});
this.subscriptions.add(
atom.config.onDidChange(`${name}.bleedingUpdates`, ({newValue}) => {
if (!newValue) { localStorage.set('didUnsubscribeFromBleedingUpdates', Date.now()) }
updater.checkForUpdate()
})
)

this.subscriptions.add(
atom.config.onDidChange(`${name}.notifier`, ({newValue}) => {
newValue ? this.activateNotifier() : this.notifier.deactivate()
})
)

this.subscriptions.add(
atom.config.onDidChange(`${name}.terminalColors.basic`, () => colors.apply())
)

this.subscriptions.add(
atom.config.onDidChange(`${name}.terminalColors.ansi`, () => colors.apply())
)

this.subscriptions.add(
atom.config.onDidChange(`${name}.terminalColors.json`, ({newValue}) => {
colors.parseJSON(newValue);
})
)

var openPath = localStorage.get('learnOpenLabOnActivation');
if (openPath) {
Expand Down
12 changes: 10 additions & 2 deletions lib/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {learnCo} from './config'
import {name} from '../package.json'

var helpCenterUrl = `${learnCo}/ide/faq`;
var latestVersionUrl = `${learnCo}/api/v1/learn_ide/latest_version`;

function latestVersionUrl() {
var bleedingUpdates = atom.config.get(`${name}.bleedingUpdates`);
return bleedingUpdates ? `${learnCo}/api/v1/learn_ide/bleeding_version` : `${learnCo}/api/v1/learn_ide/latest_version`
}

export default {
autoCheck() {
Expand Down Expand Up @@ -79,7 +83,7 @@ export default {
},

_fetchLatestVersionData() {
return fetch(latestVersionUrl).then(latestVersionData => {
return fetch(latestVersionUrl()).then(latestVersionData => {
this.latestVersionData = latestVersionData;
return this.latestVersionData;
});
Expand All @@ -100,6 +104,10 @@ export default {
_shouldUpdate(latestVersion) {
var {version} = require('../package.json');

if (localStorage.remove('didUnsubscribeFromBleedingUpdates')) {
return !semver.eq(latestVersion, version)
}

if (semver.gt(latestVersion, version)) {
return true;
}
Expand Down
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,22 @@
"underscore-plus": "^1.6.6"
},
"configSchema": {
"notifier": {
"bleedingUpdates": {
"order": 0,
"type": "boolean",
"default": false,
"title": "Subscribe to Bleeding Updates",
"description": "Recieve update notifications as beta and early releases of the Learn IDE become available. Learn more on the [help center](https://learn.co/ide/bleeding)."
},
"notifier": {
"order": 1,
"type": "boolean",
"default": true,
"title": "Learn Status Notifications",
"description": "Receive desktop notifications that correspond to the lights on Learn.co"
"description": "Receive desktop notifications that correspond to the lights on Learn.co."
},
"terminalColors": {
"order": 1,
"order": 2,
"type": "object",
"properties": {
"basic": {
Expand Down

0 comments on commit 9299b7e

Please sign in to comment.