Refine Delete Conversation

This commit is contained in:
kevinzhow
2015-10-07 20:53:44 +08:00
parent 1e5e546982
commit 2879e075d2
6 changed files with 42 additions and 5 deletions
+2 -2
View File
@@ -274,7 +274,7 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="1984" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="nGo-Vv-zCO" customClass="BorderTextField" customModule="Yep" customModuleProvider="target">
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="nGo-Vv-zCO" customClass="BorderTextField" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="195" width="600" height="60"/>
<animations/>
<constraints>
@@ -781,7 +781,7 @@
<fontDescription key="fontDescription" name="Helvetica-Light" family="Helvetica" pointSize="18"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="1984" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="ofP-ec-R5d" customClass="BorderTextField" customModule="Yep" customModuleProvider="target">
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="ofP-ec-R5d" customClass="BorderTextField" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="195" width="600" height="60"/>
<animations/>
<constraints>
+1
View File
@@ -231,6 +231,7 @@ class FayeService: NSObject, MZFayeClientDelegate {
private func saveMessageWithMessageInfo(messageInfo: JSONDictionary) {
// realmQueue realmQueue
dispatch_async(dispatch_get_main_queue()) {
guard let realm = try? Realm() else {
return
}
+16
View File
@@ -1274,6 +1274,22 @@ func joinGroup(groupID groupID: String, failureHandler: ((Reason, String?) -> Vo
}
func leaveGroup(groupID groupID: String, failureHandler: ((Reason, String?) -> Void)?, completion: JSONDictionary -> Void) {
let parse: JSONDictionary -> JSONDictionary? = { data in
return data
}
let resource = authJsonResource(path: "/api/v1/circles/\(groupID)/leave", method: .DELETE, requestParameters: [:], parse: parse)
if let failureHandler = failureHandler {
apiRequest({_ in}, baseURL: baseURL, resource: resource, failure: failureHandler, completion: completion)
} else {
apiRequest({_ in}, baseURL: baseURL, resource: resource, failure: defaultFailureHandler, completion: completion)
}
}
func headGroups(failureHandler failureHandler: ((Reason, String?) -> Void)?, completion: JSONDictionary -> Void) {
let requestParameters = [
"page": 1,
@@ -39,7 +39,7 @@ class ConversationsViewController: UIViewController {
}
}
lazy var noConversationFooterView: InfoView = InfoView(NSLocalizedString("Do not do to others what you would not like to be done to you.", comment: ""))
lazy var noConversationFooterView: InfoView = InfoView(NSLocalizedString("All conversations will show at here.", comment: ""))
var noConversation = false {
didSet {
@@ -345,7 +345,27 @@ extension ConversationsViewController: UITableViewDataSource, UITableViewDelegat
// delete conversation, finally
realm.write {
if let group = conversation.withGroup {
if let feed = conversation.withGroup?.withFeed {
realm.delete(feed)
}
let groupID = group.groupID
leaveGroup(groupID: groupID, failureHandler: { (reason, error) -> Void in
}, completion: { (result) -> Void in
})
realm.delete(group)
}
realm.delete(conversation)
}
}
+1 -1
View File
@@ -624,7 +624,7 @@
"Fetching" = "Fetching";
"Do not do to others what you would not like to be done to you." = "Do not do to others what you would not like to be done to you.";
"All conversations will show at here." = "All conversations will show at here.";
"No discovered users." = "No discovered users.";
+1 -1
View File
@@ -626,7 +626,7 @@
"Fetching" = "收取中…";
"Do not do to others what you would not like to be done to you." = "己所不欲,勿施于人";
"All conversations will show at here." = "所有对话都会显示在这里.";
"No discovered users." = "没有发现其他用户";