mirror of
https://bitbucket.org/vendoo/vendoo_v1.0.git
synced 2025-12-25 11:47:40 +00:00
Merged branch RDB-Notification-Manager into Rapid-Dev-Branch
This commit is contained in:
commit
c4aa936973
Binary file not shown.
@ -282,7 +282,9 @@
|
|||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "403"
|
startingLineNumber = "403"
|
||||||
endingLineNumber = "403">
|
endingLineNumber = "403"
|
||||||
|
landmarkName = "listingHasNewNotifications(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||||
|
landmarkType = "5">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
<BreakpointProxy
|
<BreakpointProxy
|
||||||
@ -296,7 +298,9 @@
|
|||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "410"
|
startingLineNumber = "410"
|
||||||
endingLineNumber = "410">
|
endingLineNumber = "410"
|
||||||
|
landmarkName = "listingHasNewNotifications(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||||
|
landmarkType = "5">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
<BreakpointProxy
|
<BreakpointProxy
|
||||||
@ -583,7 +587,7 @@
|
|||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "310"
|
startingLineNumber = "310"
|
||||||
endingLineNumber = "310"
|
endingLineNumber = "310"
|
||||||
landmarkName = "listingHasNewNotifications(_:ebayInfo:amazonInfo:etsyInfo:)"
|
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||||
landmarkType = "5">
|
landmarkType = "5">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
@ -599,7 +603,7 @@
|
|||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "313"
|
startingLineNumber = "313"
|
||||||
endingLineNumber = "313"
|
endingLineNumber = "313"
|
||||||
landmarkName = "listingHasNewNotifications(_:ebayInfo:amazonInfo:etsyInfo:)"
|
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||||
landmarkType = "5">
|
landmarkType = "5">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
@ -615,7 +619,7 @@
|
|||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "322"
|
startingLineNumber = "322"
|
||||||
endingLineNumber = "322"
|
endingLineNumber = "322"
|
||||||
landmarkName = "listingHasNewNotifications(_:ebayInfo:amazonInfo:etsyInfo:)"
|
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||||
landmarkType = "5">
|
landmarkType = "5">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
@ -631,7 +635,7 @@
|
|||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "335"
|
startingLineNumber = "335"
|
||||||
endingLineNumber = "335"
|
endingLineNumber = "335"
|
||||||
landmarkName = "listingHasNewNotifications(_:ebayInfo:amazonInfo:etsyInfo:)"
|
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||||
landmarkType = "5">
|
landmarkType = "5">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
|
|||||||
@ -232,8 +232,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ebayInfo != nil) {
|
if (ebayInfo != nil) {
|
||||||
notificationArray.append(
|
let notification = [
|
||||||
[
|
|
||||||
"network": "ebay",
|
"network": "ebay",
|
||||||
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
|
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
|
||||||
"type": (ebayInfo as! [String : AnyObject])["type"] as! String,
|
"type": (ebayInfo as! [String : AnyObject])["type"] as! String,
|
||||||
@ -241,12 +240,15 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
|
|||||||
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
|
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||||
"UUID": NSUUID().UUIDString
|
"UUID": NSUUID().UUIDString
|
||||||
]
|
]
|
||||||
|
|
||||||
|
notificationArray.append(
|
||||||
|
notification as! [String : AnyObject]
|
||||||
)
|
)
|
||||||
self.endedListings.appendContentsOf( self.userListings.filter({$0.key == ((ebayInfo as! [String : AnyObject])["listingKey"] as! String)}))
|
self.endedListings.appendContentsOf( self.userListings.filter({$0.key == ((ebayInfo as! [String : AnyObject])["listingKey"] as! String)}))
|
||||||
self.userListings = self.userListings.filter({$0.key != ((ebayInfo as! [String : AnyObject])["listingKey"] as! String)})
|
self.userListings = self.userListings.filter({$0.key != ((ebayInfo as! [String : AnyObject])["listingKey"] as! String)})
|
||||||
let itemsView = self.viewControllers![0] as! ItemTableViewController
|
let itemsView = self.viewControllers![0] as! ItemTableViewController
|
||||||
|
|
||||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((ebayInfo as! [String : AnyObject])["listingKey"] as! String))").observeSingleEventOfType( .Value, withBlock: {
|
/*self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((ebayInfo as! [String : AnyObject])["listingKey"] as! String))").observeSingleEventOfType( .Value, withBlock: {
|
||||||
(snapshot) -> Void in
|
(snapshot) -> Void in
|
||||||
|
|
||||||
var listingDict = snapshot.value as? [String : AnyObject]
|
var listingDict = snapshot.value as? [String : AnyObject]
|
||||||
@ -254,7 +256,41 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
|
|||||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((ebayInfo as! [String : AnyObject])["listingKey"] as! String))").setValue(listingDict)
|
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((ebayInfo as! [String : AnyObject])["listingKey"] as! String))").setValue(listingDict)
|
||||||
|
|
||||||
itemsView.itemTable.reloadData()
|
itemsView.itemTable.reloadData()
|
||||||
|
})*/
|
||||||
|
|
||||||
|
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType( .Value, withBlock: {
|
||||||
|
(snapshot) -> Void in
|
||||||
|
|
||||||
|
var userDict = snapshot.value as? [String : AnyObject]
|
||||||
|
var notifications = userDict!["notifications"] as? [String: AnyObject]
|
||||||
|
|
||||||
|
if notifications == nil {
|
||||||
|
userDict!["notifications"] = [((ebayInfo as! [String : AnyObject])["listingKey"] as! String):notification]
|
||||||
|
}else {
|
||||||
|
notifications![((ebayInfo as! [String : AnyObject])["listingKey"] as! String)] = notification
|
||||||
|
userDict!["notifications"] = notifications
|
||||||
|
}
|
||||||
|
|
||||||
|
var listings = userDict!["user_Listings"] as! [String: AnyObject]
|
||||||
|
var listingDict = (listings[((ebayInfo as! [String : AnyObject])["listingKey"] as! String)] as! [String : AnyObject])
|
||||||
|
listingDict["listingStatus"] = "Ended"
|
||||||
|
|
||||||
|
//save everything back to their respective dictionaries
|
||||||
|
listings[((ebayInfo as! [String : AnyObject])["listingKey"] as! String)] = listingDict
|
||||||
|
userDict!["user_Listings"] = listings
|
||||||
|
|
||||||
|
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").setValue(userDict, withCompletionBlock: {
|
||||||
|
(error, reference) -> Void in
|
||||||
|
|
||||||
|
if error == nil {
|
||||||
|
//reload data for notifications
|
||||||
|
NSUserDefaults.standardUserDefaults().setObject(notificationArray, forKey: "notifications")
|
||||||
|
itemsView.itemTable.reloadData()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amazonInfo != nil) {
|
if (amazonInfo != nil) {
|
||||||
@ -271,8 +307,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (etsyInfo != nil) {
|
if (etsyInfo != nil) {
|
||||||
notificationArray.append(
|
let notification = [
|
||||||
[
|
|
||||||
"network": "etsy",
|
"network": "etsy",
|
||||||
"message": (etsyInfo as! [String : AnyObject])["notification"] as! String,
|
"message": (etsyInfo as! [String : AnyObject])["notification"] as! String,
|
||||||
"type": "ended",
|
"type": "ended",
|
||||||
@ -280,23 +315,44 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
|
|||||||
"key": (etsyInfo as! [String : AnyObject])["listingKey"] as! String,
|
"key": (etsyInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||||
"UUID": NSUUID().UUIDString
|
"UUID": NSUUID().UUIDString
|
||||||
]
|
]
|
||||||
|
notificationArray.append(
|
||||||
|
notification as! [String : AnyObject]
|
||||||
)
|
)
|
||||||
self.endedListings.appendContentsOf( self.userListings.filter({$0.key == ((etsyInfo as! [String : AnyObject])["listingKey"] as! String)}))
|
self.endedListings.appendContentsOf( self.userListings.filter({$0.key == ((etsyInfo as! [String : AnyObject])["listingKey"] as! String)}))
|
||||||
self.userListings = self.userListings.filter({$0.key != ((etsyInfo as! [String : AnyObject])["listingKey"] as! String)})
|
self.userListings = self.userListings.filter({$0.key != ((etsyInfo as! [String : AnyObject])["listingKey"] as! String)})
|
||||||
let itemsView = self.viewControllers![0] as! ItemTableViewController
|
let itemsView = self.viewControllers![0] as! ItemTableViewController
|
||||||
|
|
||||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((etsyInfo as! [String : AnyObject])["listingKey"] as! String))").observeSingleEventOfType( .Value, withBlock: {
|
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType( .Value, withBlock: {
|
||||||
(snapshot) -> Void in
|
(snapshot) -> Void in
|
||||||
|
|
||||||
var listingDict = snapshot.value as? [String : AnyObject]
|
var userDict = snapshot.value as? [String : AnyObject]
|
||||||
listingDict!["listingStatus"] = "Ended"
|
var notifications = userDict!["notifications"] as? [String: AnyObject]
|
||||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((etsyInfo as! [String : AnyObject])["listingKey"] as! String))").setValue(listingDict)
|
|
||||||
|
|
||||||
|
if notifications == nil {
|
||||||
|
userDict!["notifications"] = [((etsyInfo as! [String : AnyObject])["listingKey"] as! String):notification]
|
||||||
|
}else {
|
||||||
|
notifications![((etsyInfo as! [String : AnyObject])["listingKey"] as! String)] = notification
|
||||||
|
userDict!["notifications"] = notifications
|
||||||
|
}
|
||||||
|
|
||||||
|
var listings = userDict!["user_Listings"] as! [String: AnyObject]
|
||||||
|
var listingDict = (listings[((etsyInfo as! [String : AnyObject])["listingKey"] as! String)] as! [String : AnyObject])
|
||||||
|
listingDict["listingStatus"] = "Ended"
|
||||||
|
|
||||||
|
//save everything back to their respective dictionaries
|
||||||
|
listings[((etsyInfo as! [String : AnyObject])["listingKey"] as! String)] = listingDict
|
||||||
|
userDict!["user_Listings"] = listings
|
||||||
|
|
||||||
|
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").setValue(userDict, withCompletionBlock: {
|
||||||
|
(error, reference) -> Void in
|
||||||
|
|
||||||
|
if error == nil {
|
||||||
//reload data for notifications
|
//reload data for notifications
|
||||||
NSUserDefaults.standardUserDefaults().setObject(notificationArray, forKey: "notifications")
|
NSUserDefaults.standardUserDefaults().setObject(notificationArray, forKey: "notifications")
|
||||||
itemsView.itemTable.reloadData()
|
itemsView.itemTable.reloadData()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,8 +68,48 @@ extension NotificationsViewController: UITableViewDelegate {
|
|||||||
self.presentViewController(alert, animated: true, completion: nil)
|
self.presentViewController(alert, animated: true, completion: nil)
|
||||||
break
|
break
|
||||||
case "ebay":
|
case "ebay":
|
||||||
|
let alert = UIAlertController(title: "New Notification", message: "Would you like to dismiss this notification?", preferredStyle: .Alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "Mark as Dismissed", style: .Default, handler: {
|
||||||
|
(action) -> Void in
|
||||||
|
|
||||||
|
notification["seen"] = true
|
||||||
|
self.notifications[indexPath.row] = notification
|
||||||
|
self.fireBase.ref.child("Users/\(self.fireBase.user_email)/notifications/\(notification["UUID"] as! String)").setValue(notification, withCompletionBlock: {
|
||||||
|
(error, reference) -> Void in
|
||||||
|
|
||||||
|
if error == nil {
|
||||||
|
self.notifications = self.notifications.filter({$0["seen"] as! Bool == false})
|
||||||
|
NSUserDefaults.standardUserDefaults().setObject(self.notifications, forKey: "notifications")
|
||||||
|
self.notificationTable.reloadData()
|
||||||
|
alert.dismissViewControllerAnimated(true, completion: nil)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}))
|
||||||
|
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: {(action) -> Void in}))
|
||||||
|
self.presentViewController(alert, animated: true, completion: nil)
|
||||||
break
|
break
|
||||||
case "etsy":
|
case "etsy":
|
||||||
|
let alert = UIAlertController(title: "New Notification", message: "Would you like to dismiss this notification?", preferredStyle: .Alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "Mark as Dismissed", style: .Default, handler: {
|
||||||
|
(action) -> Void in
|
||||||
|
|
||||||
|
notification["seen"] = true
|
||||||
|
self.notifications[indexPath.row] = notification
|
||||||
|
self.fireBase.ref.child("Users/\(self.fireBase.user_email)/notifications/\(notification["UUID"] as! String)").setValue(notification, withCompletionBlock: {
|
||||||
|
(error, reference) -> Void in
|
||||||
|
|
||||||
|
if error == nil {
|
||||||
|
self.notifications = self.notifications.filter({$0["seen"] as! Bool == false})
|
||||||
|
NSUserDefaults.standardUserDefaults().setObject(self.notifications, forKey: "notifications")
|
||||||
|
self.notificationTable.reloadData()
|
||||||
|
alert.dismissViewControllerAnimated(true, completion: nil)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}))
|
||||||
|
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: {(action) -> Void in}))
|
||||||
|
self.presentViewController(alert, animated: true, completion: nil)
|
||||||
break
|
break
|
||||||
case "amazon":
|
case "amazon":
|
||||||
break
|
break
|
||||||
@ -85,16 +125,18 @@ extension NotificationsViewController: UITableViewDataSource {
|
|||||||
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
||||||
let cell: NotificationTableViewCell! = self.notificationTable.dequeueReusableCellWithIdentifier("notification_cell") as! NotificationTableViewCell
|
let cell: NotificationTableViewCell! = self.notificationTable.dequeueReusableCellWithIdentifier("notification_cell") as! NotificationTableViewCell
|
||||||
let notification = self.notifications[indexPath.row]
|
let notification = self.notifications[indexPath.row]
|
||||||
cell.message.text = notification["notification"] as! String
|
|
||||||
|
|
||||||
switch ( notification["network"] as! String) {
|
switch ( notification["network"] as! String) {
|
||||||
case "facebook":
|
case "facebook":
|
||||||
|
cell.message.text = notification["notification"] as! String
|
||||||
cell.network.image = UIImage(named: "facebook_icon")
|
cell.network.image = UIImage(named: "facebook_icon")
|
||||||
break
|
break
|
||||||
case "ebay":
|
case "ebay":
|
||||||
|
cell.message.text = notification["message"] as! String
|
||||||
cell.network.image = UIImage(named: "ebay_icon")
|
cell.network.image = UIImage(named: "ebay_icon")
|
||||||
break
|
break
|
||||||
case "etsy":
|
case "etsy":
|
||||||
|
cell.message.text = notification["message"] as! String
|
||||||
cell.network.image = UIImage(named: "etsy_icon")
|
cell.network.image = UIImage(named: "etsy_icon")
|
||||||
break
|
break
|
||||||
case "amazon":
|
case "amazon":
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user