Beispiel #1
0
        public NewTootBoxViewModel(IReactiveProperty <Status> inReplyTo, IMastodonClient client)
        {
            this.inReplyTo = inReplyTo;
            this.client    = client;
            InReplyTo      = inReplyTo.ToReadOnlyReactiveProperty();

            TootCommand = Text.Select(t => t.Length > 0)
                          .ToAsyncReactiveCommand()
                          .WithSubscribe(executeTootCommand);
            CancelReplyCommand = this.inReplyTo
                                 .Select(svm => svm != null)
                                 .ToReactiveCommand()
                                 .WithSubscribe(() => this.inReplyTo.Value = null);

            this.inReplyTo.Subscribe(status =>
            {
                if (status == null)
                {
                    InReplyToText.Value = null;
                }
                else
                {
                    Status OriginalStatus = status.Reblog ?? status;
                    InReplyToText.Value   = $"To: {OriginalStatus.Account.UserName}: {OriginalStatus.Content}";
                    Text.Value            = $"@{OriginalStatus.Account.AccountName} {Text.Value}";
                }
            });
        }
 public MastodonApiWrapper(Registration registration, UserMastodonConnectionDetails userMastodonConnectionDetails, IAuthenticationClient authClient = null, IMastodonClient mastodonClient = null)
 {
     AppRegistration = registration;
     MastodonHostInstance = AppRegistration?.Instance;
     UserMastodonConnectionDetails = userMastodonConnectionDetails;
     _authClient = authClient;
     _mastodonClient = mastodonClient;
 }
Beispiel #3
0
 public NotificationsModel(IMastodonClient client)
 {
     this.client      = client;
     streaming        = this.client.GetUserStreaming();
     StreamingStarted = streamingStarted.ToReadOnlyReactiveProperty();
     StreamingStarting.DistinctUntilChanged().Subscribe(OnStreamingChanged);
     streaming.OnNotification += Streaming_OnNotification;
 }
Beispiel #4
0
        public NotificationsViewModel(NotificationTabParameters param, IMastodonClient client) : base(param, null)
        {
            model                  = new NotificationsModel(client);
            Notifications          = new ReadOnlyObservableCollection <Notification>(model);
            IsStreaming            = model.StreamingStarted;
            ReloadCommand          = new AsyncReactiveCommand().WithSubscribe(() => model.FetchPreviousAsync());
            ReloadOlderCommand     = new AsyncReactiveCommand().WithSubscribe(() => model.FetchNextAsync());
            ToggleStreamingCommand = new ReactiveCommand().WithSubscribe(() => model.StreamingStarting.Value = !IsStreaming.Value);

            model.StreamingStarting.Value = param.StreamingOnStartup;
            ReloadCommand.Execute();
        }
Beispiel #5
0
 protected TimelineModelBase(IMastodonClient client)
 {
     this.client      = client;
     StreamingStarted = streamingStarted.ToReadOnlyReactiveProperty();
     streaming        = GetStreaming();
     if (streaming != null)
     {
         streaming.OnUpdate += Streaming_OnUpdate;
         streaming.OnDelete += Streaming_OnDelete;
     }
     StreamingStarting.DistinctUntilChanged().Subscribe(OnStreamingChanged);
 }
        private IMastodonClient GetOrCreateMastodonClient()
        {
            if (_mastodonClient == null)
            {
                if (AppRegistration == null)
                {
                    throw new ArgumentNullException(nameof(AppRegistration));
                }
                if (UserMastodonConnectionDetails == null)
                {
                    throw new ArgumentNullException(nameof(UserMastodonConnectionDetails));
                }
                _mastodonClient = new MastodonClient(AppRegistration.ToMastodonAppRegistration(), UserMastodonConnectionDetails.ToMastodonAuth());
            }

            return _mastodonClient;
        }
 public MastodonApiWrapper(Registration registration, IAuthenticationClient authClient = null, IMastodonClient mastodonClient = null)
     : this(registration, null, authClient, mastodonClient)
 {
 }
 public MastodonApiWrapper(string mastodonHostInstance, IAuthenticationClient authClient = null, IMastodonClient mastodonClient = null)
     : this(null as Registration, authClient, mastodonClient)
 {
     MastodonHostInstance = mastodonHostInstance;
 }
 public MastodonApiWrapper(IAuthenticationClient authClient = null, IMastodonClient mastodonClient = null)
     : this(null as string, authClient, mastodonClient) { }
Beispiel #10
0
        public TimelineViewModel(TimelineTabParameters param, IReactiveProperty <Status> inReplyTo, TabsModel tabs, IMastodonClient client) : base(param, inReplyTo)
        {
            switch (param.Type)
            {
            case TimelineType.Home:
                Statuses = new StatusesViewModel(new HomeTimelineModel(client), inReplyTo, tabs, param.StreamingOnStartup);
                break;

            case TimelineType.Local:
                Statuses = new StatusesViewModel(new LocalTimelineModel(client), inReplyTo, tabs, param.StreamingOnStartup);
                break;

            case TimelineType.Federated:
                Statuses = new StatusesViewModel(new FederatedTimelineModel(client), inReplyTo, tabs, param.StreamingOnStartup);
                break;
            }
        }
Beispiel #11
0
 public AccountTimelineModel(long id, IMastodonClient client) : base(client)
 {
     Id = id;
 }
Beispiel #12
0
 public FederatedTimelineModel(IMastodonClient client) : base(client)
 {
 }
Beispiel #13
0
 public LocalTimelineModel(IMastodonClient client) : base(client)
 {
 }
Beispiel #14
0
 public HomeTimelineModel(IMastodonClient client) : base(client)
 {
 }
        public static TabContentViewModelBase FromParam(TabParameters param, IReactiveProperty <Status> inReplyTo, TabsModel tabs, IMastodonClient client)
        {
            switch (param)
            {
            case AccountTabParameters aparam:
                return(new AccountTabViewModel(aparam, inReplyTo, tabs, client));

            case TimelineTabParameters tparam:
                return(new TimelineViewModel(tparam, inReplyTo, tabs, client));

            case NotificationTabParameters nparam:
                return(new NotificationsViewModel(nparam, client));

            default:
                throw new NotImplementedException();
            }
        }
Beispiel #16
0
 public AccountTabViewModel(AccountTabParameters param, IReactiveProperty <Status> inReplyTo, TabsModel tabs, IMastodonClient client) : base(param, inReplyTo)
 {
     GetAccount(param.Id);
     Statuses = new StatusesViewModel(new AccountTimelineModel(param.Id, client), inReplyTo, tabs);
 }