예제 #1
0
 public void UpdateOrInsert(int id, Octokit.Notification note, Response details)
 {
     if (this.ContainsKey(id))
     {
         this[id].HtmlUrl      = details.HtmlUrl;
         this[id].RepoFullName = note.Repository.FullName;
         this[id].UserLogin    = details.User.Login;
         this[id].UserId       = details.User.Id;
         this[id].SubjectTitle = note.Subject.Title;
         this[id].Body         = details.Body;
         //this[id].TimeStamp = details.UpdatedAt;
     }
     else
     {
         var notification = new Notification()
         {
             Id           = id,
             HtmlUrl      = details.HtmlUrl,
             RepoFullName = note.Repository.FullName,
             UserLogin    = details.User.Login,
             UserId       = details.User.Id,
             SubjectTitle = note.Subject.Title,
             Body         = details.Body,
             TimeStamp    = details.UpdatedAt
         };
         this.Add(id, notification);
     }
 }
예제 #2
0
        private async Task Read(Octokit.Notification model)
        {
            // If its already read, ignore it
            if (!model.Unread)
            {
                return;
            }

            try
            {
                if (!int.TryParse(model.Id, out int id))
                {
                    return;
                }

                await _applicationService.GitHubClient.Activity.Notifications.MarkAsRead(id);

                if (_shownIndex != 2)
                {
                    Notifications.Items.Remove(model);
                }

                UpdateAccountNotificationsCount();
            }
            catch
            {
                DisplayAlert("Unable to mark notification as read. Please try again.");
            }
        }
예제 #3
0
     public void UpdateOrInsert(int id, Octokit.Notification note, Response details)
     {
         if (this.ContainsKey(details.User.Id))
         {
             if (this[details.User.Id].Notifications == null)
             {
                 this[details.User.Id].Notifications = new int[] { }
             }
             ;
             if (!this[details.User.Id].Notifications.Contains(id))
             {
                 this[details.User.Id].Notifications.Concat(new int[] { id });
             }
             this[details.User.Id].Login     = details.User.Login;
             this[details.User.Id].AvatarUrl = details.User.AvatarUrl;
             //this[details.User.Id].TimeStamp = details.UpdatedAt;
         }
         else
         {
             var user = new User()
             {
                 Id            = details.User.Id,
                 Login         = details.User.Login,
                 AvatarUrl     = details.User.AvatarUrl,
                 Notifications = new int[] { id },
                 TimeStamp     = DateTimeHelper.ParsedOrDefaultDateTime(details.UpdatedAt)
             };
             this.Add(details.User.Id, user);
         }
     }
 }
예제 #4
0
     public void UpdateOrInsert(int id, Octokit.Notification note, Response details)
     {
         if (this.ContainsKey(note.Repository.Id))
         {
             if (this[note.Repository.Id].Notifications == null)
             {
                 this[note.Repository.Id].Notifications = new int[] { }
             }
             ;
             if (!this[note.Repository.Id].Notifications.Contains(id))
             {
                 this[note.Repository.Id].Notifications.Concat(new int[] { id });
             }
             this[note.Repository.Id].RepoFullName = note.Repository.FullName;
             //this[note.Repository.Id].LastReadAt = details.UpdatedAt;
         }
         else
         {
             var repository = new Repository()
             {
                 Id            = note.Repository.Id,
                 RepoFullName  = note.Repository.FullName,
                 LastReadAt    = DateTimeHelper.ParsedOrDefaultDateTime(details.UpdatedAt),
                 Notifications = new int[] { id }
             };
             this.Add(note.Repository.Id, repository);
         }
     }
 }
예제 #5
0
        public static async Task UpdateTile(Octokit.Notification notification)
        {
            var tile = await notification.BuildTiles(TilesTextStyles.Base, TilesTextStyles.SubtitleSubtle,
                                                     TilesTextStyles.Body, TilesVisualBrandings.NameAndLogo);

            UpdateTile(tile, tile.Tag);
        }
예제 #6
0
        private async Task ReadNotification(Octokit.Notification notification)
        {
            if (notification == null || !notification.Unread)
            {
                return;
            }
            await _applicationService.GitHubClient.Notification.MarkAsRead(int.Parse(notification.Id));

            _notifications.Remove(notification);
        }
예제 #7
0
파일: JsonHelper.cs 프로젝트: fbmnds/GitMe
        public static string DeserializeToOctokitNotification(Octokit.Notification note)
        {
            var contents = new StringBuilder();

            contents.Append("{");
            contents.Append(string.Format("\"{0}\": {1},", "id", note.Id));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "lastreadat", note.LastReadAt));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "reason", note.Reason));
            contents.Append("\"repository\": \n{");
            contents.Append(string.Format("\"{0}\": \"{1}\",", "cloneurl", note.Repository.CloneUrl));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "createdat", note.Repository.CreatedAt));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "defaultbranch", note.Repository.DefaultBranch));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "description", note.Repository.Description));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "fork", note.Repository.Fork));
            contents.Append(string.Format("\"{0}\": {1},", "forkscount", note.Repository.ForksCount));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "fullname", note.Repository.FullName));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "giturl", note.Repository.GitUrl));
            contents.Append(string.Format("\"{0}\": {1},", "hasdownloads", note.Repository.HasDownloads));
            contents.Append(string.Format("\"{0}\": {1},", "hasissues", note.Repository.HasIssues));
            contents.Append(string.Format("\"{0}\": {1},", "haswiki", note.Repository.HasWiki));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "homepage", note.Repository.Homepage));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "htmlurl", note.Repository.HtmlUrl));
            contents.Append(string.Format("\"{0}\": {1},", "id", note.Repository.Id));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "language", note.Repository.Language));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "mirrorurl", note.Repository.MirrorUrl));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "name", note.Repository.Name));
            contents.Append(string.Format("\"{0}\": {1},", "openissuescount", note.Repository.OpenIssuesCount));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "organization", note.Repository.Organization));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "owner", note.Repository.Owner));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "parent", note.Repository.Parent));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "private", note.Repository.Private));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "pushedat", note.Repository.PushedAt));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "source", note.Repository.Source));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "sshurl", note.Repository.SshUrl));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "svnurl", note.Repository.SvnUrl));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "updatedat", note.Repository.UpdatedAt));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "url", note.Repository.Url));
            contents.Append(string.Format("\"{0}\": {1}", "watcherscount", note.Repository.WatchersCount));
            contents.Append("},");
            contents.Append("\"subject\": \n{");
            contents.Append(string.Format("\"{0}\": \"{1}\",", "latestcommenturl", note.Subject.LatestCommentUrl));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "title", note.Subject.Title));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "type", note.Subject.Type));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "url", note.Subject.Url));
            contents.Append("},");
            contents.Append(string.Format("\"{0}\": \"{1}\",", "unread", note.Unread));
            contents.Append(string.Format("\"{0}\": \"{1}\",", "updatedat", note.UpdatedAt));
            contents.Append(string.Format("\"{0}\": \"{1}\"", "url", note.Url));
            contents.Append("}");

            return(contents.ToString());
        }
예제 #8
0
        private void GoToNotification(Octokit.Notification x)
        {
            var subject = x.Subject.Type.ToLower();

            if (subject.Equals("issue"))
            {
                Read(x).ToBackground();
                var node = x.Subject.Url.Substring(x.Subject.Url.LastIndexOf('/') + 1);
                ShowViewModel <IssueViewModel>(new IssueViewModel.NavObject {
                    Username = x.Repository.Owner.Login, Repository = x.Repository.Name, Id = long.Parse(node)
                });
            }
            else if (subject.Equals("pullrequest"))
            {
                Read(x).ToBackground();
                var node = x.Subject.Url.Substring(x.Subject.Url.LastIndexOf('/') + 1);
                ShowViewModel <PullRequestViewModel>(new PullRequestViewModel.NavObject {
                    Username = x.Repository.Owner.Login, Repository = x.Repository.Name, Id = long.Parse(node)
                });
            }
            else if (subject.Equals("commit"))
            {
                Read(x).ToBackground();
                var node = x.Subject.Url.Substring(x.Subject.Url.LastIndexOf('/') + 1);
                ShowViewModel <ChangesetViewModel>(new ChangesetViewModel.NavObject {
                    Username = x.Repository.Owner.Login, Repository = x.Repository.Name, Node = node
                });
            }
            else if (subject.Equals("release"))
            {
                Read(x).ToBackground();
                ShowViewModel <RepositoryViewModel>(new RepositoryViewModel.NavObject {
                    Username = x.Repository.Owner.Login, Repository = x.Repository.Name
                });
            }
        }
예제 #9
0
 private static Action <object> MakeCallback(WeakReference <NotificationsViewModel> weakVm, Octokit.Notification model)
 {
     return(new Action <object>(_ => weakVm.Get()?.GoToNotificationCommand.Execute(model)));
 }
예제 #10
0
 public static async Task <bool> Like(this ToastNotification toast, Octokit.Notification notification)
 {
     return(toast.Like(await notification.BuildToast(ToastNotificationScenario.Reminder)));
 }
예제 #11
0
        public static async Task <ToastNotification> PopCustomToast(Octokit.Notification notification, ToastNotificationScenario scenario = ToastNotificationScenario.Default)
        {
            var toast = await notification.BuildToast(scenario);

            return(PopCustomToast(toast, toast.Tag, toast.Group));
        }