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

Create option to subscribe to bleeding updates #457

Merged
merged 3 commits into from
May 12, 2017
Merged
Show file tree
Hide file tree
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
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