Ejemplo n.º 1
0
        /// <summary>
        /// The add link.
        /// </summary>
        /// <param name="link">
        /// The link.
        /// </param>
        public void AddLink(Link link)
        {
            if (!this.settingsStore.ShowInNewLinks(link.StreamKey))
            {
                if (NewSlapsChanged != null)
                {
                    NewSlapsChanged(this, link);
                }

                return;
            }

            var links = this.Links;

            // Link already exists but trigger a refresh
            if (links.Any(l => l.Id == link.Id))
            {
                if (NewSlapsChanged != null)
                {
                    NewSlapsChanged(this, link);
                }

                return;
            }

            this.links.Insert(0, link);
            Storage.Save(Key, this.links.Take(10).ToList());

            // this.UpdateBadge(links);

            if (NewSlapsChanged != null)
            {
                NewSlapsChanged(this, link);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The new slaps store on new slaps changed.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="link">
        /// The link.
        /// </param>
        private void NewSlapsStoreOnNewSlapsChanged(object sender, Link link)
        {
            if (link == null)
            {
                return;
            }

            var linkId = link.Id;
            this.CrossThread(
                () =>
                {
                    var oldLinks = this.viewModel.NewLinks.Where(l => l.Id == linkId).ToList();

                    if (oldLinks.Any())
                    {
                        this.viewModel.NewLinks.RemoveRange(oldLinks);
                    }
                    else if (this.settingsStore.ShowInNewLinks(link.StreamKey))
                    {
                        this.viewModel.NewLinks.Insert(0, Mapper.Map<Link, LinkViewModel>(link));
                    }
                });
        }