Remove redundant signal

This commit is contained in:
bleakgrey 2018-04-14 20:53:09 +03:00
parent 54605b898c
commit f5e9b4f2dc
5 changed files with 24 additions and 15 deletions

View File

@ -2,7 +2,7 @@ using GLib;
public class Tootle.AccountManager : Object{
public abstract signal void changed_current(Account account);
public abstract signal void changed_current(Account? account);
public abstract signal void added(Account account);
public abstract signal void removed(Account account);
@ -89,7 +89,7 @@ public class Tootle.AccountManager : Object{
var access_token = root.get_string_member ("access_token");
settings.access_token = access_token;
debug ("Got access token");
Tootle.app.state_updated ();
update_current ();
}
catch (GLib.Error e) {
warning ("Can't get access token");
@ -115,4 +115,9 @@ public class Tootle.AccountManager : Object{
return msg;
}
public void logout (){
current = null;
changed_current ();
}
}

View File

@ -8,7 +8,6 @@ namespace Tootle{
public class Application : Granite.Application {
public abstract signal void state_updated();
public abstract signal void toast(string title);
public abstract signal void error(string error);
@ -32,6 +31,11 @@ namespace Tootle{
protected override void activate () {
window.present ();
var has_token = AccountManager.instance.has_access_token();
if(has_token)
AccountManager.instance.update_current ();
else
AccountManager.instance.changed_current (null);
}
}

View File

@ -22,8 +22,7 @@ public class Tootle.MainWindow: Gtk.Window {
set_titlebar (header);
window_position = WindowPosition.CENTER;
Tootle.app.state_updated.connect(on_state_update);
on_state_update ();
AccountManager.instance.changed_current.connect(on_account_changed);
}
construct {
@ -72,19 +71,16 @@ public class Tootle.MainWindow: Gtk.Window {
NetManager.instance.finished.connect (() => spinner.hide ());
}
private void on_state_update(){
private void on_account_changed(Account? account){
mode.hide ();
button_toot.hide ();
accounts.hide ();
stack.forall (widget => stack.remove (widget));
var has_token = AccountManager.instance.has_access_token();
if(!has_token)
if(account == null)
show_setup_views ();
else
show_main_views ();
AccountManager.instance.update_current ();
}
private void show_setup_views (){

View File

@ -28,7 +28,8 @@ public class Tootle.HomeView : Tootle.AbstractView {
this.pars = pars;
show_all();
request_update ();
AccountManager.instance.changed_current.connect(on_account_changed);
// var s = new Status(1);
// s.content = "Test content, wow!";
@ -49,7 +50,10 @@ public class Tootle.HomeView : Tootle.AbstractView {
view.pack_end (widget, false, false, 0);
}
public virtual Soup.Message request_update (){
public virtual void on_account_changed (Account? account){
if(account == null)
return;
var url = Settings.instance.instance_url;
url += "api/v1/timelines/";
url += this.timeline;
@ -71,7 +75,6 @@ public class Tootle.HomeView : Tootle.AbstractView {
warning (e.message);
}
});
return msg;
}
}

View File

@ -35,6 +35,7 @@ public class Tootle.AccountsButton : Gtk.MenuButton{
show_all ();
AccountManager.instance.changed_current.connect (account => {
if (account != null)
CacheManager.instance.load_avatar (account.avatar, avatar, 24);
});
}