Esempio n. 1
0
        public Conversation(Item initialPost)
        {
            items = new ThreadSaveObservableCollection <Item>();
            if (initialPost == null)
            {
                return;
            }
            startingPointPost = initialPost;
            this.displayName  = "Conversation with @" + initialPost.user.username;
            if (initialPost.apnMessage == null)
            {
                Tuple <List <Post>, ApiCallResponse> conversation = Posts.getRepliesById(AppController.Current.account.accessToken, initialPost.id);
                if (conversation.Item2.success)
                {
                    foreach (Post post in conversation.Item1)
                    {
                        items.Add(new Item(post));
                    }
                }
            }
            else
            {
                Tuple <List <Message>, ApiCallResponse> conversation = Messages.getMessagesInChannel(AppController.Current.account.accessToken, initialPost.apnMessage.channel_id);
                if (conversation.Item2.success)
                {
                    foreach (Message message in conversation.Item1)
                    {
                        items.Add(new Item(message));
                    }
                }
            }

            this.id = "conversation_" + initialPost.id;
        }
Esempio n. 2
0
 public PatterRoom(Channel subscribedChannel)
 {
     if (subscribedChannel == null)
     {
         return;
     }
     displayName              = "No name";
     items                    = new ThreadSaveObservableCollection <Item>();
     items.CollectionChanged += items_CollectionChanged;
     channel                  = subscribedChannel;
     if (channel.annotations != null)
     {
         foreach (Annotation annotation in channel.annotations)
         {
             if (annotation.type == "net.patter-app.settings")
             {
                 if (annotation.parsedObject != null)
                 {
                     AppNetDotNet.Model.Annotations.Patter settings = annotation.parsedObject as AppNetDotNet.Model.Annotations.Patter;
                     if (settings != null)
                     {
                         displayName = settings.name;
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
        public PrivateMessageChannel(Channel subscribedChannel)
        {
            if (subscribedChannel == null)
            {
                return;
            }
            displayName              = "";
            items                    = new ThreadSaveObservableCollection <Item>();
            items.CollectionChanged += items_CollectionChanged;
            channel                  = subscribedChannel;

            if (channel.owner.username != AppController.Current.account.username)
            {
                displayName = "@" + channel.owner.username + ", ";
            }
            List <string> already_added_ids = new List <string>();

            if (channel.readers != null)
            {
                foreach (string user_id in  channel.readers.user_ids)
                {
                    if (user_id == AppController.Current.account.user.id || already_added_ids.Contains(user_id))
                    {
                        continue;
                    }
                    Tuple <AppNetDotNet.Model.User, AppNetDotNet.ApiCalls.ApiCallResponse> response = AppNetDotNet.ApiCalls.Users.getUserByUsernameOrId(AppController.Current.account.accessToken, user_id);
                    if (response.Item2.success)
                    {
                        already_added_ids.Add(user_id);
                        displayName += "@" + response.Item1.username + ", ";
                    }
                }
            }
            if (channel.writers != null)
            {
                foreach (string user_id in  channel.writers.user_ids)
                {
                    if (user_id == AppController.Current.account.user.id || already_added_ids.Contains(user_id))
                    {
                        continue;
                    }
                    Tuple <AppNetDotNet.Model.User, AppNetDotNet.ApiCalls.ApiCallResponse> response = AppNetDotNet.ApiCalls.Users.getUserByUsernameOrId(AppController.Current.account.accessToken, user_id);
                    if (response.Item2.success)
                    {
                        already_added_ids.Add(user_id);
                        displayName += "@" + response.Item1.username + ", ";
                    }
                }
            }
            displayName = displayName.TrimEnd();
            displayName = displayName.TrimEnd(',');
        }
Esempio n. 4
0
        public Search(string name, string query, string access_token)
        {
            items             = new ThreadSaveObservableCollection <Item>();
            this.displayName  = name;
            this.id           = query;
            this.access_token = access_token;

            backgroundWorkerUpdateItems = new BackgroundWorker();
            backgroundWorkerUpdateItems.WorkerReportsProgress      = true;
            backgroundWorkerUpdateItems.WorkerSupportsCancellation = true;
            backgroundWorkerUpdateItems.DoWork             += backgroundWorkerUpdateItems_DoWork;
            backgroundWorkerUpdateItems.RunWorkerCompleted += backgroundWorkerUpdateItems_RunWorkerCompleted;
            backgroundWorkerUpdateItems.ProgressChanged    += backgroundWorkerUpdateItems_ProgressChanged;
        }