Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Fix redirect URL on gh pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Mar 14, 2017
1 parent ecfa0c2 commit 2ed617a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ update message model =
{ model | lock = True, content = "", passphrase = "", error = "Wrong passphrase" } ! []

Lock ->
{ model | lock = True, gearMenuOpen = False, content = "", passphrase = "" } ! [ encryptData { content = model.content, passphrase = model.passphrase } ]
{ model | lock = True, gearMenuOpen = False, content = "", passphrase = "", error = "" } ! [ encryptData { content = model.content, passphrase = model.passphrase } ]

DataSaved key ->
case key of
Expand Down
31 changes: 16 additions & 15 deletions ports.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ function getItem(key) {

function setItem(key, value) {
if (!IS_WEB_EXTENSION) {
localStorage.setItem(key, value);
if (value === null) {
localStorage.removeItem(key);
} else {
localStorage.setItem(key, value);
}
return Promise.resolve(null);
} else {
return new Promise(function(resolve, reject) {
Expand Down Expand Up @@ -62,19 +66,14 @@ function createElmApp(flags) {
});

app.ports.saveData.subscribe(function(data) {
let promise;
if (data.content === null) {
promise = removeItem(data.key);
} else {
promise = setItem(data.key, data.content);
}
promise.then(function() {
app.ports.dataSaved.send(data.key);
})
.catch(function(err) {
console.error(err);
app.ports.newError.send('Nothing retrieved: ' + err.message);
});
setItem(data.key, data.content)
.then(function() {
app.ports.dataSaved.send(data.key);
})
.catch(function(err) {
console.error(err);
app.ports.newError.send('Nothing retrieved: ' + err.message);
});
});

app.ports.decryptData.subscribe(function(data) {
Expand Down Expand Up @@ -116,7 +115,9 @@ function createElmApp(flags) {

app.ports.enableSync.subscribe(function(content) {
if (!IS_WEB_EXTENSION) {
document.location.href = "https://kinto.dev.mozaws.net/v1/fxa-oauth/login?redirect=http://localhost:8000/%23auth=";
const {origin, pathname} = document.location;
const redirect = encodeURIComponent(`${origin}${pathname}#auth=`);
document.location.href = "https://kinto.dev.mozaws.net/v1/fxa-oauth/login?redirect=" + redirect;
} else {
getItem('fxaToken')
.then(function(fxaToken) {
Expand Down

0 comments on commit 2ed617a

Please sign in to comment.