Open fuzzyfox opened 12 years ago
To help anyone wishing to use the notification system here are the method calls I have defined... Note: the notification object may be attached to something else or renamed, however I will try and keep the methods the same.
/**
* Add notification to queue
*
* @param array details up-to two items, produces two lines, first line is bold
* @param integer priority optional, the priority level of notice
* @param string icon option, name of an icon to show
* @return integer notice id, can be used to remove/modify notice
*/
notification.add(details, priority, icon) {};
/**
* Remove notification from queue
*
* @param integer notice_id the id of the notice to remove
* @return void
*/
notification.remove(notice_id) {};
/**
* Modify notification in queue
*
* @param integer notice_id the id of the notice to modify
* @param array details up-to two items, produces two lines, first line is bold
* @param integer priority optional, the priority level of notice
* @param string icon option, name of an icon to show
* @return integer notice id, can be used to remove/modify notice
*/
notification.modify(notice_id, details, priority, icon) {};
/**
* Checks if a notification is still queued
*
* @param integer notice_id the id of the notice to check for
* @return boolean TRUE if notice exists still
*/
notification.exists(notice_id) {};
Notifications will be queued so as to not just stack a whole bunch of notices on top of each other in the UI... it will also be good practice to modify notifications where possible before they are sent to the UI (e.g. if a session changes twice and the user has not yet been notified).
These methods will be server side, and sent to the device when the device requests update. (current undefined interval).
NB: This setup is free for dispute / change if needed... its just the easiest and most future proof method I can think of right now.
Is there any method like pop() to retrieve the first notification ? And something like hasNew() maybe ?
I've worked on a notification system of my own, based on what's above.
var notification = function(){
var queue = [];
/**
* Add notification to queue
*
* @param string resource reference to the updated resource
* @param array details up-to two items, produces two lines, first line is bold
* @param boolean toAll if true the notification is seen by everybody, otherwise only those who have subscribed to the resource will see it
* @param string icon option, name of an icon to show
* @return integer notice id, can be used to remove/modify notice
*/
this.add = function(resource, details, toAll, icon) {};
/**
* Get notifications for the resource we've subscribed to and which we haven't already seen
*
* @param array resources references to the resources
* @param array seen all the notifications we've already seen
* @return array notifications notification objects with all the details
*/
this.get = function(resources, seen) {};
/**
* Remove notification from queue
*
* @param integer notice_id the id of the notice to remove
* @return void
*/
this.remove = function(notice_id) {};
/**
* Modify notification in queue
*
* @param integer notice_id the id of the notice to modify
* @param array details optional, up-to two items, produces two lines, first line is bold
* @param boolean toAll if true the notification is seen by everybody, otherwise only those who have subscribed to the resource will see it
* @param string icon option, name of an icon to show
* @return integer notice id, can be used to remove/modify notice
*/
this.modify = function(notice_id, details, toAll, icon) {};
};
Do you see any problem with my idea ? Can I start developing it ?
No, infact it seems a neater solution to the one I had planned. Go ahead and work on it. I was not going to start filling in my code till tomorrow so its not a problem.
I will work on getting that new view created.
I think we need some server-side persistence for the queue to be sure we don't lose it in a crash !
make it so :)
William Duyck :: Mozilla Rep / Student / Geek :: www.wduyck.com :: protocol.by/wduyck
On Tuesday, 4 September 2012 at 23:02, Erwan Guyader wrote:
I think we need some server-side persistence for the queue to be sure we don't lose it in a crash !
— Reply to this email directly or view it on GitHub (https://github.com/brianking/events-app/issues/2#issuecomment-8280682).
I'm not familiar with Node so I'm wondering if the variable queue is shared between all the users or not.
So node is the server side bit, and due to the way queue
is declared its not accessible outside the notifications object anyway.
William Duyck :: Mozilla Rep / Student / Geek :: www.wduyck.com :: protocol.by/wduyck
On Wednesday, 5 September 2012 at 17:48, Erwan Guyader wrote:
I'm not familiar with Node so I'm wondering if the variable queue is shared between all the users or not.
— Reply to this email directly or view it on GitHub (https://github.com/brianking/events-app/issues/2#issuecomment-8305461).
Ok then my question is : is the notifications object shared between users ?
Another way to say that is : what part of the project is server-side js and what part is client-side js ? I'm a little confused with that and it would help me a lot to understand it.
Create a notification system that can be used across the app for notifications about schedule changes, etc... should be easy to use and provide simple usage.
bonus: can accept notifications for any update (e.g. session, promos [possible future uses], app-updates, etc...)