Originally I was looking through all the PHP events to see what was available, but realized quickly this must all be done from JS.
I have Notifications working for Desktop and Mobile, but now need to hook into events to be able to send them properly.
Naturally, we'll probably AT LEAST want Notifications on receiving a New Message. Going through all the JS that gets served I've found this, but can anyone make any sense of it and how I could access or use from another script:
Anyone understand this JS?
MAILBOX_ConversationItem = Backbone.Model.extend({
selected: false,
initialize: function(){
var conversationUnread = OWM.Mailbox.unreadMessageList.findWhere({convId: this.get('conversationId')});
if ( conversationUnread ){
this.set({selected: true});
}
var that = this;
OW.bind('mailbox.new_message_notification', function(data){
if (data.message.convId == that.get('conversationId')){
that.set({selected: true});
}
});
}
});
I need to listen for this event in my own JS script, but can't access OW (undefined):
OW.bind('mailbox.new_message_notification', function(data){
if (data.message.convId == that.get('conversationId')){
that.set({selected: true});
}
});
The only other option is editing the mailbox static JS script when the plugin installs, but I believe this against the plugin rules...
This is for Mobile Only so I have to hook into onPing to handle Desktop, because there doesn't seem to be an equivalent event to listen to for Desktop for when a new message is received, unless someone knows better?