Save serverId to settings

This commit is contained in:
angelblue05 2016-09-04 19:14:25 -05:00
parent 71abbd4129
commit feda0cb9df

View file

@ -43,17 +43,20 @@ class InitialSetup(object):
###$ Begin transition phase $### ###$ Begin transition phase $###
if settings('server') == "": if settings('server') == "":
current_server = self.user_client.get_server() current_server = self.user_client.get_server()
self.connectmanager.get_server(current_server) server = self.connectmanager.get_server(current_server)
settings('ServerId', value=server['Id'])
self.user_client.get_userid() self.user_client.get_userid()
self.user_client.get_token() self.user_client.get_token()
###$ End transition phase $### ###$ End transition phase $###
if settings('server'):
current_state = self.connectmanager.get_state() current_state = self.connectmanager.get_state()
if current_state['State'] == STATE['SignedIn']: for server in current_state['Servers']:
server = current_state['Servers'][0] if server['Id'] == settings('serverId'):
server_address = self.connectmanager.get_address(server) server_address = self.connectmanager.get_address(server)
self._set_server(server_address, server['Name']) self._set_server(server_address, server)
self._set_user(server['UserId'], server['AccessToken']) self._set_user(server['UserId'], server['AccessToken'])
break
return return
try: try:
@ -67,7 +70,7 @@ class InitialSetup(object):
else: else:
server_address = self.connectmanager.get_address(server) server_address = self.connectmanager.get_address(server)
self._set_server(server_address, server['Name']) self._set_server(server_address, server)
if not server.get('AccessToken') and not server.get('UserId'): if not server.get('AccessToken') and not server.get('UserId'):
try: try:
@ -113,11 +116,11 @@ class InitialSetup(object):
settings('streamMusic', value="true") settings('streamMusic', value="true")
@classmethod @classmethod
def _set_server(cls, server, name): def _set_server(cls, server_address, server):
settings('serverName', value=name) settings('serverName', value=server['Name'])
settings('server', value=server) settings('serverId', value=server['Id'])
log.info("Saved server information: %s", server) settings('server', value=server_address)
@classmethod @classmethod
def _set_user(cls, user_id, token): def _set_user(cls, user_id, token):