Skip to content
Snippets Groups Projects
Commit 43dcb317 authored by jakobsbode's avatar jakobsbode
Browse files

Merge remote-tracking branch 'origin/master'

parents 66333d01 bb0b7af6
No related branches found
No related tags found
No related merge requests found
......@@ -267,6 +267,7 @@
A1EB05761D9567F2008659C1 /* read */,
A1EB05751D956748008659C1 /* send */,
A13526781D955BDF00D3BFE1 /* AppDelegate.swift */,
A1EB05871D956879008659C1 /* AddressHandler.swift */,
A1EB059B1D956957008659C1 /* NSDateCompare.swift */,
A1EB05911D95692A008659C1 /* MailObject.swift */,
A1EB059D1D956963008659C1 /* EnzevalosContact.swift */,
......@@ -309,7 +310,6 @@
A1EB057D1D956848008659C1 /* VENDataDelegate.swift */,
A1EB05811D95685B008659C1 /* CollectionDataDelegate.swift */,
A1EB05831D956867008659C1 /* TableViewDataDelegate.swift */,
A1EB05871D956879008659C1 /* AddressHandler.swift */,
A1EB05791D956829008659C1 /* ContactCell.swift */,
A1EB05851D956872008659C1 /* FrequentCell.swift */,
A1EB05891D956890008659C1 /* ContactCell.xib */,
......@@ -324,8 +324,8 @@
A1EB058F1D956923008659C1 /* ReadViewController.swift */,
F12041FA1DA3FBF7002E4940 /* ListViewController.swift */,
F12041FC1DA409A5002E4940 /* ListViewCell.swift */,
A1EB05931D956931008659C1 /* InboxCellDelegator.swift */,
F12060811DA552FC00F6EF37 /* MailHandlerDelegator.swift */,
A1EB05931D956931008659C1 /* InboxCellDelegator.swift */,
A1EB05951D956939008659C1 /* InboxTableViewCell.swift */,
A1EB05971D956947008659C1 /* InboxViewController.swift */,
F120607F1DA540FE00F6EF37 /* RefreshControlExtension.swift */,
......
......@@ -27,9 +27,9 @@ class EnzevalosContact: Comparable {
}
func ==(lhs: EnzevalosContact, rhs: EnzevalosContact) -> Bool {
return lhs.mails.maxElement()!.time == rhs.mails.maxElement()!.time
return lhs.mails.first!.time == rhs.mails.first!.time
}
func <(lhs: EnzevalosContact, rhs: EnzevalosContact) -> Bool {
return lhs.mails.maxElement()!.time > rhs.mails.maxElement()!.time
return lhs.mails.first!.time > rhs.mails.first!.time
}
......@@ -46,9 +46,9 @@ class InboxTableViewCell: UITableViewCell {
var enzContact: EnzevalosContact? {
didSet {
if let con = enzContact {
self.firstMail = con.mails.last
self.firstMail = con.mails.first
if con.mails.count > 1 {
self.secondMail = con.mails[con.mails.endIndex - 2]
self.secondMail = con.mails[1]
}
self.contact = con.contact
}
......
......@@ -13,9 +13,15 @@
<rect key="frame" x="0.0" y="0.0" width="400" height="130"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="CFu-ns-kay" id="iQP-01-jFC" userLabel="Container">
<frame key="frameInset" width="400" height="129.5"/>
<frame key="frameInset" width="400" height="129"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="uDO-9h-a86" userLabel="Icon View">
<constraints>
<constraint firstAttribute="width" constant="30" id="Zf5-eH-DtF"/>
<constraint firstAttribute="height" constant="30" id="n7I-Eu-a0k"/>
</constraints>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="WNp-Ty-Hv1">
<constraints>
<constraint firstAttribute="height" constant="70" id="Bei-PK-STi"/>
......@@ -94,12 +100,6 @@
<action selector="firstButtonPressed:" destination="CFu-ns-kay" eventType="touchUpInside" id="YFb-kT-nNt"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="uDO-9h-a86" userLabel="Icon View">
<constraints>
<constraint firstAttribute="width" constant="30" id="Zf5-eH-DtF"/>
<constraint firstAttribute="height" constant="30" id="n7I-Eu-a0k"/>
</constraints>
</imageView>
</subviews>
<constraints>
<constraint firstItem="Woe-Z6-TzX" firstAttribute="leading" secondItem="6Ac-fp-DaH" secondAttribute="trailing" constant="-498" id="1Xo-Rd-5M9"/>
......
......@@ -14,12 +14,10 @@ class InboxViewController : UITableViewController, InboxCellDelegator, MailHandl
var contacts: [EnzevalosContact] = [] {
didSet {
self.contacts.sortInPlace()
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.tableView.reloadData()
print("Refreshed TableView")
})
}
}
let mailHandler = MailHandler()
@IBOutlet weak var lastUpdateButton: UIBarButtonItem!
......@@ -34,9 +32,9 @@ class InboxViewController : UITableViewController, InboxCellDelegator, MailHandl
var lastUpdate: NSDate?
func addNewMail(mail: Mail) {
var isAdded = false
for contact in contacts {
for address in contact.contact.emailAddresses {
print("addr: \(address.value) sender: \(mail.sender?.mailbox)")
if address.value as? String == mail.sender?.mailbox {
// Kontakt existiert bereits
if !contact.mails.contains(mail) {
......@@ -74,7 +72,7 @@ class InboxViewController : UITableViewController, InboxCellDelegator, MailHandl
tableView.sectionFooterHeight = 0
self.refreshControl?.addTarget(self, action: #selector(InboxViewController.refresh(_:)), forControlEvents: UIControlEvents.ValueChanged)
// self.refreshControl?.attributedTitle = NSAttributedString(string: "Pull to refresh")
self.refreshControl?.attributedTitle = NSAttributedString(string: "Pull to refresh")
lastUpdateLabel.sizeToFit()
lastUpdateLabel.backgroundColor = UIColor.clearColor()
......@@ -92,7 +90,6 @@ class InboxViewController : UITableViewController, InboxCellDelegator, MailHandl
}
func refresh(refreshControl: UIRefreshControl) {
print("refresh")
lastUpdateText = "Updating..."
self.mailHandler.recieve()
}
......@@ -102,6 +99,8 @@ class InboxViewController : UITableViewController, InboxCellDelegator, MailHandl
lastUpdate = NSDate()
rc.endRefreshing()
lastUpdateText = "Just refreshed"
self.contacts.sortInPlace()
self.tableView.reloadData()
}
}
......
......@@ -105,9 +105,9 @@ class MailHandler {
if UInt64(message.uid) > biggest {
biggest = UInt64(message.uid)
}
dispatch_group_enter(dispatchGroup)
let op = self.IMAPSession!.fetchMessageByUIDOperationWithFolder(folder, uid: message.uid)
op.start { (err, data) -> Void in
dispatch_group_enter(dispatchGroup)
let msgParser = MCOMessageParser(data: data)
let html: String = msgParser.plainTextBodyRendering()
var rec: [MCOAddress] = []
......@@ -118,17 +118,17 @@ class MailHandler {
rec.append(r as! MCOAddress)
}
}
let mail = Mail(uid: message.uid, sender: header.from, receivers: rec, time: header.date, received: true, subject: "UID: \(message.uid) \(header.subject)", body: html, isEncrypted: false, isVerified: false, trouble: false, isUnread: !messageRead)
let mail = Mail(uid: message.uid, sender: header.from, receivers: rec, time: header.date, received: true, subject: header.subject, body: html, isEncrypted: false, isVerified: false, trouble: false, isUnread: !messageRead)
self.delegate?.addNewMail(mail)
dispatch_group_leave(dispatchGroup)
}
self.lastUID = biggest
}
dispatch_group_notify(dispatchGroup, dispatch_get_main_queue()) {
print("All Done!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
self.delegate?.getMailCompleted()
}
self.IMAPSession?.disconnectOperation().start({_ in })
}
}
}
......
......@@ -80,5 +80,5 @@ func ==(lhs: Mail, rhs: Mail) -> Bool {
}
func <(lhs: Mail, rhs: Mail) -> Bool {
return lhs.time < rhs.time
return lhs.time > rhs.time
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment