 is_important = (x) -> not x.seen and x.actions?['comment']
 
 update_important_count = (recalculate) ->
-    if recalculate
+    if recalculate and notifications_syncdb?
         important_count = (x for x in notifications_syncdb.select(where:{table:'activity'}) when is_important(x)).length
 
     if important_count == 0

    #console.log("render_notifications")
    notification_list_body.empty()
    important_count = 0
    v = notifications_syncdb.select(where:{table:'activity'})
    v.sort(misc.timestamp_cmp)
    ensure_titles_and_user_names v, () =>

        update_important_count(false)

delete_oldest_notification = () ->
    if not notifications_syncdb?
        return
    v = notifications_syncdb.select(where:{table:'activity'})
    v.sort(misc.timestamp_cmp)
    if v.length > 0
