Improved error handling.

This commit is contained in:
Martin Edenhofer 2016-05-18 00:27:05 +02:00
parent dff4a03208
commit dc263fb92a
2 changed files with 29 additions and 17 deletions

View file

@ -38,10 +38,15 @@ class Index extends App.ControllerContent
channel = App.Channel.find(channel_id) channel = App.Channel.find(channel_id)
if channel && channel.options && channel.options.sync if channel && channel.options && channel.options.sync
displayName = '-' displayName = '-'
if channel.options.sync.wall.group_id if channel.options.sync.wall && channel.options.sync.wall.group_id
group = App.Group.find(channel.options.sync.wall.group_id) group = App.Group.find(channel.options.sync.wall.group_id)
displayName = group.displayName() displayName = group.displayName()
if !channel.options.sync
channel.options.sync = {}
if !channel.options.sync.wall
channel.options.sync.wall = {}
channel.options.sync.wall.groupName = displayName channel.options.sync.wall.groupName = displayName
if channel.options && channel.options.pages
for page in channel.options.pages for page in channel.options.pages
displayName = '-' displayName = '-'
for page_id, pageParams of channel.options.sync.pages for page_id, pageParams of channel.options.sync.pages
@ -114,6 +119,9 @@ class Index extends App.ControllerContent
e.preventDefault() e.preventDefault()
id = $(e.target).closest('.action').data('id') id = $(e.target).closest('.action').data('id')
channel = App.Channel.find(id) channel = App.Channel.find(id)
if !channel
@navigate '#channels/facebook'
return
if !channel.options.sync if !channel.options.sync
channel.options.sync = {} channel.options.sync = {}
if !channel.options.sync.wall if !channel.options.sync.wall
@ -136,6 +144,7 @@ class Index extends App.ControllerContent
el.html(selection) el.html(selection)
groupSelection(channel.options.sync.wall.group_id, content.find('.js-wall .js-groups'), 'wall') groupSelection(channel.options.sync.wall.group_id, content.find('.js-wall .js-groups'), 'wall')
if channel.options.pages
for page in channel.options.pages for page in channel.options.pages
pageConfigured = false pageConfigured = false
for page_id, pageParams of channel.options.sync.pages for page_id, pageParams of channel.options.sync.pages

View file

@ -119,6 +119,9 @@ class Index extends App.ControllerContent
e.preventDefault() e.preventDefault()
id = $(e.target).closest('.action').data('id') id = $(e.target).closest('.action').data('id')
channel = App.Channel.find(id) channel = App.Channel.find(id)
if !channel
@navigate '#channels/twitter'
return
content = $( App.view('twitter/account_edit')(channel: channel) ) content = $( App.view('twitter/account_edit')(channel: channel) )
createGroupSelection = (selected_id, prefix) -> createGroupSelection = (selected_id, prefix) ->