Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Notify on mention #3

Closed
colindean opened this issue Jun 26, 2014 · 23 comments
Closed

Notify on mention #3

colindean opened this issue Jun 26, 2014 · 23 comments

Comments

@colindean
Copy link
Owner

No idea how to do this, but it's a blocker for day-to-day usage of this app.

@colindean
Copy link
Owner Author

Looks like there are two ways:

It seems like Growl does more of what I want, but it might be valuable to let the user decide in some kind of menu option.

@colindean colindean changed the title Make desktop notifications work Notify on mention Jun 26, 2014
@colindean
Copy link
Owner Author

There's another app that seems to observe title changes to catch events.

@colindean
Copy link
Owner Author

@jwheare is one the case!

@jwheare
Copy link

jwheare commented Jun 29, 2014

We're now calling macgap.notice.notify whenever we'd open a web notification.

@colindean
Copy link
Owner Author

Awesome. I'll check it out.

@colindean
Copy link
Owner Author

What I'm noticing is that, when someone privmsgs me, I don't get a notification. I don't recall hearing a sound, either. When I click on the channel/nick that has mentions/messages, the chat pane goes away and clicking on any of the channels does nothing. Other links work, as does expanding the archive, though. Only way to get anything back is to restart the app.

@jwheare
Copy link

jwheare commented Jun 29, 2014

Presumably there's a way to see the javascript console and error log?

@colindean
Copy link
Owner Author

Yeah… I need to turn on MacGap’s debug.

@colindean
Copy link
Owner Author

defaults write com.IRCCloud developer 1

@colindean
Copy link
Owner Author

In the console:

Hmm, now the chat pane isn’t loading at all, and it appears that Finder is crashing when the app loads…

[Error] Error: -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x600000037e20
    render (app-bundle-0b14ab5e.js, line 15)
    triggerEvents (backbone-1.0.0.min.js, line 1)
    trigger (backbone-1.0.0.min.js, line 1)
    _onModelEvent (backbone-1.0.0.min.js, line 1)
    triggerEvents (backbone-1.0.0.min.js, line 1)
    trigger (backbone-1.0.0.min.js, line 1)
    setUnseen (app-bundle-0b14ab5e.js, line 3)
    addMessage (app-bundle-0b14ab5e.js, line 3)
    handleMessage (app-bundle-0b14ab5e.js, line 4)
    triggerEvents (backbone-1.0.0.min.js, line 1)
    trigger (backbone-1.0.0.min.js, line 1)
    (anonymous function) (app-bundle-0b14ab5e.js, line 5)
    triggerEvents (backbone-1.0.0.min.js, line 1)
    trigger (backbone-1.0.0.min.js, line 1)
    triggerMessageEvent (app-bundle-0b14ab5e.js, line 1)
    processMessage (app-bundle-0b14ab5e.js, line 1)
    (anonymous function) (app-bundle-0b14ab5e.js, line 1)
    forEach
    forEach (underscore-1.5.2.min.js, line 5)
    processOob (app-bundle-0b14ab5e.js, line 1)
    (anonymous function)
    (anonymous function) (app-bundle-0b14ab5e.js, line 1)
    (anonymous function)
    (anonymous function) (app-bundle-0b14ab5e.js, line 1)
    (anonymous function)
    j (jquery-2.1.0.min.js, line 4)
    fireWith (jquery-2.1.0.min.js, line 4)
    x (jquery-2.1.0.min.js, line 6)
    (anonymous function) (jquery-2.1.0.min.js, line 6)

@colindean
Copy link
Owner Author

So poking around at the Javascript, I think I found the issue, and it's in the dock badge (#4):

window.macgap.dock.badge = s || ""

I think it doesn't like that the badge is getting set to an empty string.

@colindean
Copy link
Owner Author

Nope, good theory, but wrong. Just tried this in a new MacGap project:

<a href="#" onclick="macgap.dock.badge='1'">One</a>
<a href="#" onclick="macgap.dock.badge='0'">Zero</a>
<a href="#" onclick="macgap.dock.badge=''">No badge</a>

and it worked as it should.

@colindean
Copy link
Owner Author

found it.

<a href="#" onclick="macgap.dock.badge=1">One int</a>

badge likes numbers as strings, not integers.

@jwheare
Copy link

jwheare commented Jun 29, 2014

Is it supposed to be set to 0 then?

On 29 Jun 2014, at 18:30, Colin Dean [email protected] wrote:

So poking around at the Javascript, I think I found the issue, and it's in
the dock badge (#4 #4):

window.macgap.dock.badge = s || ""

I think it doesn't like that the badge is getting set to an empty string.


Reply to this email directly or view it on GitHub
#3 (comment).

@jwheare
Copy link

jwheare commented Jun 29, 2014

Ah ok sorry, replied before reading the full thread. I'll cast it to a
string.

On 29 Jun 2014, at 18:35, Colin Dean [email protected] wrote:

found it.

One int

badge likes numbers as strings, not integers.


Reply to this email directly or view it on GitHub
#3 (comment).

@colindean
Copy link
Owner Author

@jwheare, with what I found out in #9, can you use macgap.growl.notify({title: "", content: ""}) until I can get us moved to MacGap 2 in #10?

@colindean
Copy link
Owner Author

Scratch that. I created my own copy of the macgap gem and updated it (#11).

I think once you get the badge issue fixed, then I can make sure that things work.

@colindean
Copy link
Owner Author

@jwheare, I'm still not seeing any notifications from IRCCloud.app. In doing some testing, it looks like the Notification Center notifications aren't working at all.

Could you switch to Growl? At least until #10 is pretty much ready? That likely won't be until MG2 is 1.0'd.

@jwheare
Copy link

jwheare commented Jul 18, 2014

Done, it should be live within an hour.

@colindean
Copy link
Owner Author

So I can see the js that should be activating it, and I've had people both mention and privmsg me, but I'm still not getting any notifications. I've double checked Growl, and I can see that the app has registered itself with Growl. However, nothing is showing in the history.

Under what conditions should the notification appear?

I do see the badge, and I would assume that the notification would appear whenever there is an event that would increment the badge count.

@jwheare
Copy link

jwheare commented Jul 19, 2014

Found the issue. MacGap exposes the window.webkitNotifications and window.Notification apis but does nothing with them, so the macgap.notice calls were never being reached.

MacGap really should just be using those interfaces so that no extra code is required, but for now I've added the macgap.notice.notify call further up (native notifications do work after all). Annoyingly, MacGap doesn't let you bind an onclick event, so we can't select the right channel for a notification.

I don't know if this is improved in newer versions.

Change should be live in about 15 minutes.

@colindean
Copy link
Owner Author

Awesome. I'll check out out in a little bit.

@colindean
Copy link
Owner Author

OK, it appears to be working after refreshing the page multiple times.

screen shot 2014-07-19 at 10 32 03 am

The big difference between macgap.growl and macgap.notice, or really, between Growl and Notification Center, is the Growl will show notifications even if the app is in the foreground. Notification Center won't.

I cleared about 200 "testing" from my Notification Center after figuring this out 👅

Thank you so very much for implementing this, @jwheare! 🍻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants