Setting count = 0 doesn't remove the hub
hashmapped opened this issue · 7 comments
I am using Swift 2.1 and when I set count to 0 after a asynchronous call in completion block, it doesn't remove the red dot, and the count stays the same.
Here is my pseudocode:
// viewWillAppear
let notificationHub = RKNotificationHub(barButtonItem: self.toolBarButtonItem)
if there is an existing count {
notificationHub.increment()
}
asynchronous completion call block {
if needs to increment {
notificationHub.increment()
} else {
notificationHub.count = 0
}
}
So if there wasn't any existing count (line 2), nothing shows so that's good. But if there was an existing count and I try to remove in the completion block, it doesn't remove a hub that existing count created.
Am I doing something wrong here?
I have the same problem (I use objective c). I have a bar button item to navigate to notifications history. After the user reads all notifications and goes back to previous view controller nothing works to hide the hub. Set count to 0, set the hub to nil, nothing works. My solution is to hide the view I use to init the hub. So I have to create a view with the same frame that the button item, and hide the view.
Same problem here. I found a way to solve this.
for v in msgBtn.subviews { v.removeFromSuperview() }
It's not elegant, but it works.
i'll look into this @Oscargp1986 would you mind sharing your code? apologies for the late response, I just realized my github notifications were turned off
I can't share the code because I didn't commit it... Sorry
so I built a swift project and wasn't able to replicate the problem. open to any suggestions. It seems like the code in question is
//%%% hides the notification if the value is 0
- (void)checkZero
{
if (self.count <= 0) {
redCircle.hidden = YES;
countLabel.hidden = YES;
} else {
redCircle.hidden = NO;
if (!isIndeterminateMode) {
countLabel.hidden = NO;
}
}
}
Which seems to misbehave in asynchronous callbacks. I'll keep this open for now, and I'm willing to take a look at any PRs
if(count == 0)
{
[hub hideCount];
[hub setCircleColor:[UIColor clearColor] labelColor:[UIColor clearColor]];
}
else
{
[hub showCount];
}
[hub setCount:[[collection1 getTotalObjects] intValue]];
[hub pop];
}
The Workaround that I did to mitigate this
I happen to get this problem too.. does this got solved?