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

Commit

Permalink
Remove debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Mar 14, 2017
1 parent d156ed3 commit 7318868
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
43 changes: 26 additions & 17 deletions Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ update message model =
let
content =
if model.loadedContent == "" || model.loadedContent == "Edit here" || model.contentWasSynced then
Maybe.withDefault "Edit here" (Debug.log "new data" data)
else if model.loadedContent == Maybe.withDefault "" (Debug.log "new data" data) then
Maybe.withDefault "Edit here" data
else if model.loadedContent == Maybe.withDefault "" data then
model.loadedContent
else
model.loadedContent ++ "<br/> ==== <br/>" ++ Maybe.withDefault "" (Debug.log "new data" data)
model.loadedContent ++ "<br/> ==== <br/>" ++ Maybe.withDefault "" data

commands =
if model.fromKinto && model.loadedContent == Maybe.withDefault "" data then
Expand All @@ -248,9 +248,6 @@ update message model =

UpdateContent content ->
let
_ =
Debug.log "updated content" content

debounceCount =
model.debounceCount + 1
in
Expand All @@ -265,10 +262,24 @@ update message model =
]

NewError error ->
{ model | lock = True, content = "", passphrase = Nothing, error = "Wrong passphrase" } ! []
{ model
| lock = True
, content = ""
, passphrase = Nothing
, error = "Wrong passphrase"
}
! []

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

DataSaved key ->
case key of
Expand Down Expand Up @@ -297,7 +308,10 @@ update message model =
model ! []

DataEncrypted encrypted ->
{ model | encryptedData = Debug.log "encrypted data from js" <| Just encrypted } ! [ saveData { key = "pad", content = Encode.string encrypted }, uploadData model.fxaToken encrypted ]
{ model | encryptedData = Just encrypted }
! [ saveData { key = "pad", content = Encode.string encrypted }
, uploadData model.fxaToken encrypted
]

DataNotEncrypted error ->
{ model | error = (Debug.log "" error) } ! []
Expand Down Expand Up @@ -332,11 +346,7 @@ update message model =
{ model | fxaToken = Just token } ! [ retrieveData (Just token) ]

DataSavedInKinto result ->
let
_ =
Debug.log "kinto result" result
in
model ! [ saveData { key = "contentWasSynced", content = Encode.string "true" } ]
model ! [ saveData { key = "contentWasSynced", content = Encode.string "true" } ]

DataRetrievedFromKinto (Ok data) ->
{ model | fromKinto = True } ! [ decryptIfPassphrase model.passphrase (Just data) ]
Expand Down Expand Up @@ -393,17 +403,16 @@ retrieveData : Maybe String -> Cmd Msg
retrieveData fxaToken =
case fxaToken of
Nothing ->
(Debug.log "Nothing" Cmd.none)
Cmd.none

Just token ->
let
client =
Kinto.client kintoServer (Kinto.Bearer token)
in
(Debug.log "Something" client
client
|> Kinto.get recordResource "hoverpad-content"
|> Kinto.send DataRetrievedFromKinto
)



Expand Down
3 changes: 0 additions & 3 deletions encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,11 @@ function encrypt(passphrase, content) {
new Uint8Array(encryptedData)
);
const encrypted = arrayBufferToBase64(encryptedContent);
console.log(encrypted);
return encrypted;
});
}

function separateIvFromData(buf) {
console.log(buf, buf.length, ivLen);
const iv = new Uint8Array(ivLen);
const data = new Uint8Array(buf.length - ivLen);

Expand All @@ -102,7 +100,6 @@ function separateIvFromData(buf) {
data[i - ivLen] = byte;
}
});
console.log(iv, data);
return { iv, data };
}

Expand Down
9 changes: 0 additions & 9 deletions ports.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ function createElmApp(flags) {

app.ports.savePassphrase.subscribe(function(passphrase) {
storePassphrase(passphrase)
.then(function() {
console.log("Passphrase saved");
})
.catch(function(err) {
console.error(err);
app.ports.newError.send('Could not save passphrase: ' + err.message);
Expand All @@ -112,9 +109,6 @@ function createElmApp(flags) {

app.ports.dropPassphrase.subscribe(function() {
dropPassphrase()
.then(function() {
console.log("Passphrase dropped");
})
.catch(function(err) {
console.error(err);
app.ports.newError.send('Could not drop passphrase: ' + err.message);
Expand Down Expand Up @@ -167,7 +161,6 @@ function createElmApp(flags) {
getItem('fxaToken')
.then(function(fxaToken) {
if (fxaToken !== null) {
console.log("Bearer ", fxaToken);
app.ports.syncEnabled.send(fxaToken);
} else {
chrome.runtime.sendMessage({ action: 'authenticate' });
Expand All @@ -188,7 +181,6 @@ function createElmApp(flags) {
setItem("bearer", token)
.then(function() {
window.location.hash = "";
console.log("Bearer ", token);
app.ports.syncEnabled.send(token);
})
.catch(function(err) {
Expand All @@ -200,7 +192,6 @@ function createElmApp(flags) {
chrome.runtime.onMessage.addListener(function (eventData) {
switch (eventData.action) {
case 'authenticated':
console.log("Bearer ", eventData.bearer);
app.ports.syncEnabled.send(eventData.bearer);
break;
case 'error':
Expand Down

0 comments on commit 7318868

Please sign in to comment.