Skip to content

Commit

Permalink
Fix for new Tag API response.
Browse files Browse the repository at this point in the history
  • Loading branch information
cweirup committed Dec 14, 2020
1 parent 389ed57 commit 766e2af
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 18 deletions.
14 changes: 14 additions & 0 deletions Joplin Clipper Extension/Response.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Response.swift
// Joplin Clipper Extension
//
// Created by Christopher Weirup on 2020-12-04.
// Copyright © 2020 Christopher Weirup. All rights reserved.
//

import Foundation

struct Response: Codable {
var items: [Tag]?
var has_more: Bool?
}
12 changes: 9 additions & 3 deletions Joplin Clipper Extension/SafariExtensionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,19 @@ class SafariExtensionViewController: SFSafariExtensionViewController, NSTokenFie

Network.get(url: tagsResource.url.absoluteString) { (data, error) in
if let _data = data {
if let tags = try? JSONDecoder().decode([Tag].self, from: _data) {
for tag in tags {
let jsonData = NSString(data: _data, encoding: String.Encoding.utf8.rawValue)
NSLog("Data from loadTags = \(String(describing: jsonData))")

if let response = try? JSONDecoder().decode(Response.self, from: _data) {
for tag in response.items! {
self.builtInTagKeywords.append(tag.title ?? "")
}
}

//has_more = response.has_more == "false" ? false : true
} else { NSLog("Error parsing Tag feed") }
}
}


}

Expand Down
15 changes: 8 additions & 7 deletions Joplin Clipper Extension/Tag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import Foundation

struct Tag: Codable {
let id: String?
let parent_id: String?
let title: String?
let created_time: Int?
let updated_time: Int?
let user_created_time: Int?
let user_updated_time: Int?
let encryption_cipher_text: String?
let encryption_applied: Int?
let is_shared: Int?
// let created_time: Int?
// let updated_time: Int?
// let user_created_time: Int?
// let user_updated_time: Int?
// let encryption_cipher_text: String?
// let encryption_applied: Int?
// let is_shared: Int?
}

struct TagsResource: APIResource {
Expand Down
20 changes: 12 additions & 8 deletions Joplin Clipper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
2E0398AA257AA0C700392F68 /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E0398A9257AA0C700392F68 /* Response.swift */; };
2E73B9BF243BBE710022B356 /* Tag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E73B9BE243BBE710022B356 /* Tag.swift */; };
2E740871241C86E70011240B /* Note.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E740870241C86E70011240B /* Note.swift */; };
2E740873241C89960011240B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2E740872241C89960011240B /* Images.xcassets */; };
Expand Down Expand Up @@ -84,6 +85,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
2E0398A9257AA0C700392F68 /* Response.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Response.swift; sourceTree = "<group>"; };
2E73B9BE243BBE710022B356 /* Tag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tag.swift; sourceTree = "<group>"; };
2E740870241C86E70011240B /* Note.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Note.swift; sourceTree = "<group>"; };
2E740872241C89960011240B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -233,6 +235,7 @@
2E740872241C89960011240B /* Images.xcassets */,
2E95E62C2427090C00F1BDF7 /* NetworkManager.swift */,
2EE19ECA24400FBA00B26799 /* Network.swift */,
2E0398A9257AA0C700392F68 /* Response.swift */,
);
path = "Joplin Clipper Extension";
sourceTree = "<group>";
Expand Down Expand Up @@ -451,6 +454,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2E0398AA257AA0C700392F68 /* Response.swift in Sources */,
2E73B9BF243BBE710022B356 /* Tag.swift in Sources */,
2E95E62D2427090C00F1BDF7 /* NetworkManager.swift in Sources */,
2E95E62F2427107000F1BDF7 /* Folder.swift in Sources */,
Expand Down Expand Up @@ -552,7 +556,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -607,7 +611,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand All @@ -630,7 +634,7 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MARKETING_VERSION = 0.1;
MARKETING_VERSION = 0.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.cweirup.Joplin-Clipper-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -652,7 +656,7 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MARKETING_VERSION = 0.1;
MARKETING_VERSION = 0.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.cweirup.Joplin-Clipper-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -669,7 +673,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2884XZJMX9;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "Joplin Clipper/Info.plist";
Expand All @@ -678,7 +682,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 0.1;
MARKETING_VERSION = 0.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.cweirup.Joplin-Clipper";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -694,7 +698,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2884XZJMX9;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "Joplin Clipper/Info.plist";
Expand All @@ -703,7 +707,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 0.1;
MARKETING_VERSION = 0.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.cweirup.Joplin-Clipper";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down

0 comments on commit 766e2af

Please sign in to comment.