Skip to content

Commit

Permalink
[Chore] #520 - 임시 파일 비활성화
Browse files Browse the repository at this point in the history
  • Loading branch information
yju0808 committed Jun 14, 2024
1 parent 26a49a0 commit e3493d5
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 137 deletions.
18 changes: 8 additions & 10 deletions HappyAnding/HappyAnding.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"HappyAnding/Preview Content\"";
DEVELOPMENT_TEAM = HN3RL67C46;
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = HappyAnding/Info.plist;
Expand Down Expand Up @@ -1403,7 +1403,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"HappyAnding/Preview Content\"";
DEVELOPMENT_TEAM = HN3RL67C46;
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = HappyAnding/Info.plist;
Expand Down Expand Up @@ -1441,7 +1441,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = HN3RL67C46;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
MARKETING_VERSION = 1.0;
Expand All @@ -1463,7 +1463,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = HN3RL67C46;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
MARKETING_VERSION = 1.0;
Expand All @@ -1484,7 +1484,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = HN3RL67C46;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.happyanding.HappyAndingUITests;
Expand All @@ -1504,7 +1504,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = HN3RL67C46;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.happyanding.HappyAndingUITests;
Expand All @@ -1525,7 +1525,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = HN3RL67C46;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ShareExtension/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = ShareExtension;
Expand All @@ -1539,7 +1539,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.happyanding.HappyAnding.ShareExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = ShortcutsZipShareExtProfile_Dev_20240317;
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -1556,7 +1555,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = HN3RL67C46;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ShareExtension/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = ShareExtension;
Expand All @@ -1570,7 +1569,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.happyanding.HappyAnding.ShareExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = ShortcutsZipShareExtProfile_Dev_20240317;
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand Down
142 changes: 71 additions & 71 deletions HappyAnding/HappyAnding/Repository/SearchRepository.swift
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
////
//// SearchRepository.swift
//// HappyAnding
////
//// Created by 임정욱 on 5/2/24.
////
//
// SearchRepository.swift
// HappyAnding
//import Foundation
//import FirebaseCore
//import FirebaseFirestore
//
// Created by 임정욱 on 5/2/24.
//

import Foundation
import FirebaseCore
import FirebaseFirestore


class SearchRepository {


private let db = Firestore.firestore()
private let postCollection: String = "Post"
private let shortcutCollection: String = "Shortcut"



public func searchContentAndShortcuts(keyword: String, completion: @escaping ([[Any]]) -> Void) {
let db = Firestore.firestore()
let postsRef = db.collection(postCollection)
let shortcutsRef = db.collection(shortcutCollection)

let group = DispatchGroup()
var postsResults = [Post]()
var shortcutsResults = [Shortcuts]()
var errors: [Error] = []

let searchFieldsShortcuts = ["title", "subtitle", "description"]
for field in searchFieldsShortcuts {
group.enter()
shortcutsRef.whereField(field, arrayContains: keyword).getDocuments { (snapshot, error) in
defer { group.leave() }
if let snapshot = snapshot {
shortcutsResults += snapshot.documents.compactMap { document -> Shortcuts? in
try? document.data(as: Shortcuts.self)
}
} else if let error = error {
errors.append(error)
}
}
}

let searchFieldsPosts = ["title", "content"]
for field in searchFieldsPosts {
group.enter()
postsRef.whereField(field, arrayContains: keyword).getDocuments { (snapshot, error) in
defer { group.leave() }
if let snapshot = snapshot {
postsResults += snapshot.documents.compactMap { document -> Post? in
try? document.data(as: Post.self)
}
} else if let error = error {
errors.append(error)
}
}
}

group.notify(queue: .main) {
if errors.isEmpty {
let combinedResults = [shortcutsResults as [Any], postsResults as [Any]]
completion(combinedResults)
} else {
completion([])
}
}
}



}
//class SearchRepository {
//
//
// private let db = Firestore.firestore()
// private let postCollection: String = "Post"
// private let shortcutCollection: String = "Shortcut"
//
//
//
// public func searchContentAndShortcuts(keyword: String, completion: @escaping ([[Any]]) -> Void) {
// let db = Firestore.firestore()
// let postsRef = db.collection(postCollection)
// let shortcutsRef = db.collection(shortcutCollection)
//
// let group = DispatchGroup()
// var postsResults = [Post]()
// var shortcutsResults = [Shortcuts]()
// var errors: [Error] = []
//
// let searchFieldsShortcuts = ["title", "subtitle", "description"]
// for field in searchFieldsShortcuts {
// group.enter()
// shortcutsRef.whereField(field, arrayContains: keyword).getDocuments { (snapshot, error) in
// defer { group.leave() }
// if let snapshot = snapshot {
// shortcutsResults += snapshot.documents.compactMap { document -> Shortcuts? in
// try? document.data(as: Shortcuts.self)
// }
// } else if let error = error {
// errors.append(error)
// }
// }
// }
//
// let searchFieldsPosts = ["title", "content"]
// for field in searchFieldsPosts {
// group.enter()
// postsRef.whereField(field, arrayContains: keyword).getDocuments { (snapshot, error) in
// defer { group.leave() }
// if let snapshot = snapshot {
// postsResults += snapshot.documents.compactMap { document -> Post? in
// try? document.data(as: Post.self)
// }
// } else if let error = error {
// errors.append(error)
// }
// }
// }
//
// group.notify(queue: .main) {
// if errors.isEmpty {
// let combinedResults = [shortcutsResults as [Any], postsResults as [Any]]
// completion(combinedResults)
// } else {
// completion([])
// }
// }
// }
//
//
//
//}
112 changes: 56 additions & 56 deletions HappyAnding/HappyAnding/Views/SearchViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,62 @@
import SwiftUI

//TODO: 레포지터리 머지 시 삭제 필요
enum PostType: String, Codable {
case General = "General"
case Question = "Question"
}

struct Post: Identifiable, Codable, Equatable, Hashable {

let id : String
let type: PostType
let createdAt: String
let author: String

var content: String
var shortcuts: [String]
var images: [String]
var likedBy: [String:Bool]
var likeCount: Int
var commentCount: Int

init(type: PostType, content: String, author: String, shortcuts: [String] = [], images: [String] = []) {

self.id = UUID().uuidString
self.createdAt = Date().getDate()

self.type = type
self.content = content
self.author = author
self.shortcuts = shortcuts
self.images = images

self.likeCount = 0
self.commentCount = 0
self.likedBy = [:]

}

init() {
self.id = UUID().uuidString
self.createdAt = Date().getDate()

self.type = .General
self.content = "가나다라마바사아자차카타파하가나다라마바사아자차카타파하가나다라마바사아자차카타파하가나다라마바사아자차카타파하가나다라마바사아자차카타파하가나다라마바사아자차카타파하"
self.author = "author"
self.shortcuts = ["shortcuts"]
self.images = ["images"]

self.likeCount = 0
self.commentCount = 0
self.likedBy = [:]
}

var dictionary: [String: Any] {
let data = (try? JSONEncoder().encode(self)) ?? Data()
return (try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any]) ?? [:]
}
}
//enum PostType: String, Codable {
// case General = "General"
// case Question = "Question"
//}
//
//struct Post: Identifiable, Codable, Equatable, Hashable {
//
// let id : String
// let type: PostType
// let createdAt: String
// let author: String
//
// var content: String
// var shortcuts: [String]
// var images: [String]
// var likedBy: [String:Bool]
// var likeCount: Int
// var commentCount: Int
//
// init(type: PostType, content: String, author: String, shortcuts: [String] = [], images: [String] = []) {
//
// self.id = UUID().uuidString
// self.createdAt = Date().getDate()
//
// self.type = type
// self.content = content
// self.author = author
// self.shortcuts = shortcuts
// self.images = images
//
// self.likeCount = 0
// self.commentCount = 0
// self.likedBy = [:]
//
// }
//
// init() {
// self.id = UUID().uuidString
// self.createdAt = Date().getDate()
//
// self.type = .General
// self.content = "가나다라마바사아자차카타파하가나다라마바사아자차카타파하가나다라마바사아자차카타파하가나다라마바사아자차카타파하가나다라마바사아자차카타파하가나다라마바사아자차카타파하"
// self.author = "author"
// self.shortcuts = ["shortcuts"]
// self.images = ["images"]
//
// self.likeCount = 0
// self.commentCount = 0
// self.likedBy = [:]
// }
//
// var dictionary: [String: Any] {
// let data = (try? JSONEncoder().encode(self)) ?? Data()
// return (try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any]) ?? [:]
// }
//}

final class SearchViewModel: ObservableObject {
private let shortcutsZipViewModel = ShortcutsZipViewModel.share
Expand Down

0 comments on commit e3493d5

Please sign in to comment.