Skip to content

Commit

Permalink
Little fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maximedegreve committed Mar 16, 2015
1 parent fac5030 commit 7598f3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (getActiveTokenFromComputer() == false) {
} else {
var projectNamesArray = getProjectNamesArray()

if(projectNamesArray.count > 0){
if(projectNamesArray){
fireSendArtboards(projectNamesArray, 1)
} else{
fireError("You don\'t have any projects.","Make first a project on marvelapp.com");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (getActiveTokenFromComputer() == false) {
} else {
var projectNamesArray = getProjectNamesArray()

if(projectNamesArray.count > 0){
if(projectNamesArray){
fireSendArtboards(projectNamesArray, 0)
} else{
fireError("You don\'t have any projects.","Make first a project on marvelapp.com");
Expand Down
16 changes: 8 additions & 8 deletions Marvel/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,29 +488,29 @@ function getProjectNamesArray() {

var token = getActiveTokenFromComputer()

NSLog("token is " + token);
NSLog("token for project names fetch is " + token);

var task = NSTask.alloc().init()
task.setLaunchPath("/usr/bin/curl");

var args = NSArray.arrayWithObjects("-v", "GET", "--header", "User-Agent: Sketch", "--header", "Content-Type: application/x-www-form-urlencoded", "--header", "Authorization: Token " + token, "--header", "HTTP_AUTHORIZATION: " + token, rootURL + "project/all/", nil);
var args = NSArray.arrayWithObjects("-v", "GET", "-H", "User-Agent: Sketch", "-H", "Content-Type: application/x-www-form-urlencoded", "-H", "Authorization: Token " + token, "-H", "HTTP_AUTHORIZATION: " + token, rootURL + "project/all/", nil);
task.setArguments(args);
var outputPipe = [NSPipe pipe];
[task setStandardOutput:outputPipe];
task.launch();
var outputData = [[outputPipe fileHandleForReading] readDataToEndOfFile];

if(outputData) {

var error;

var res = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingMutableLeaves error:error];

NSLog("Convert output data to string")
var stringRead = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding];
var stringRead = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding];
NSLog("Return data " + stringRead)
NSLog("Convert output data to string finished")


var error;

var res = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingMutableLeaves error:error];;

if(res.detail && res.detail == "Invalid token"){
deleteActiveTokenFromComputer()
fireError("Your token is not valid anymore, please login again.","After you are logged in again please try again.")
Expand Down

0 comments on commit 7598f3b

Please # to comment.