lightningthunderbird-lightning

how to delete alarm in lightning (in js)


I am banging my head looking at the code for ... quite some time.

I have a lightning event, created from ics (including an alarm). I want to delete the alarm after something has occurred. I found calItemBase has mAlarms. But how to delete a single alarm? (there should be only one). What is the proper value of mAlarms if there is no alarm? What to do with mAlarmLastAck and other properties?

My workaround is to recreate from ical without the alarm, but then the user looses categories and other things he set for the event in the UI.

Many thanks,

Klaus


Solution

  • A summary of the methods intended to be public for an item can be seen here: http://mxr.mozilla.org/comm-central/source/calendar/base/public/calIItemBase.idl

    Specifically, there is a deleteAlarm method. Example:

    var alarms = item.getAlarms({});
    item.deleteAlarm(alarms[0]);
    

    If you are sure you want to delete all alarms, you can also use the clearAlarms method.

    item.clearAlarms();