mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-24 20:26:02 +10:00
Refine Delete Conversation
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.";
|
||||
|
||||
|
||||
@@ -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." = "没有发现其他用户";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user