Example #1
0
        private void UpdateStickersData(IAccountStickersData stickersData)
        {
            if (stickersData.StockItems != null)
            {
                this.StickersList = stickersData.StockItems.items;
            }
            if (stickersData.RecentStickers != null)
            {
                this.RecentStickers = stickersData.RecentStickers;
            }
            int?newStoreItemsCount = stickersData.NewStoreItemsCount;

            if (newStoreItemsCount.HasValue)
            {
                newStoreItemsCount      = stickersData.NewStoreItemsCount;
                this.NewStoreItemsCount = newStoreItemsCount.Value;
            }
            bool?hasStickersUpdates = stickersData.HasStickersUpdates;

            if (!hasStickersUpdates.HasValue)
            {
                return;
            }
            hasStickersUpdates      = stickersData.HasStickersUpdates;
            this.HasStickersUpdates = hasStickersUpdates.Value;
        }
Example #2
0
        private static void PreprocessStickersData(IAccountStickersData stickersData)
        {
            VKList <StoreProduct> vkList1  = new VKList <StoreProduct>();
            VKList <StockItem>    vkList2  = new VKList <StockItem>();
            VKList <StoreProduct> products = stickersData.Products;

            if ((products != null ? products.items :  null) != null)
            {
                VKList <StockItem> stockItems = stickersData.StockItems;
                if ((stockItems != null ? stockItems.items :  null) != null)
                {
                    List <StoreProduct> .Enumerator enumerator = stickersData.Products.items.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            StoreProduct product   = enumerator.Current;
                            StockItem    stockItem = (StockItem)Enumerable.FirstOrDefault <StockItem>(stickersData.StockItems.items, (Func <StockItem, bool>)(i => i.product.id == product.id));
                            if (stockItem != null && product != null && (product.promoted != 1 || product.purchased != 1 || product.active != 0))
                            {
                                product.description = stockItem.description;
                                product.author      = stockItem.author;
                                product.photo_140   = stockItem.photo_140;
                                vkList1.items.Add(product);
                                vkList2.items.Add(stockItem);
                            }
                        }
                    }
                    finally
                    {
                        enumerator.Dispose();
                    }
                    vkList1.count           = vkList1.items.Count;
                    vkList2.count           = vkList2.items.Count;
                    stickersData.Products   = vkList1;
                    stickersData.StockItems = vkList2;
                }
            }
            StoreStickers recentStickers = stickersData.RecentStickers;

            if ((recentStickers != null ? recentStickers.sticker_ids :  null) == null)
            {
                return;
            }
            stickersData.RecentStickers.sticker_ids = (List <int>)Enumerable.ToList <int>(Enumerable.Take <int>(stickersData.RecentStickers.sticker_ids, 32));
        }
Example #3
0
        public void UpdateStickersDataAndAutoSuggest(IAccountStickersData stickersData)
        {
            if (stickersData == null)
            {
                return;
            }
            StickersSettings.PreprocessStickersData(stickersData);
            List <StockItem>   stickersList  = this.StickersList;
            VKList <StockItem> stockItems    = stickersData.StockItems;
            List <StockItem>   stockItemList = stockItems != null ? stockItems.items :  null;
            int num = StickersSettings.GetStickersAreUpToDate((IReadOnlyList <StockItem>)stickersList, (IReadOnlyList <StockItem>)stockItemList) ? 1 : 0;

            this.UpdateStickersData(stickersData);
            if (num == 0)
            {
                return;
            }
            StickersAutoSuggestDictionary.Instance.EnsureDictIsLoadedAndUpToDate(true);
        }
Example #4
0
        private static void PreprocessStickersData(IAccountStickersData stickersData)
        {
            VKList <StoreProduct> vkList1  = new VKList <StoreProduct>();
            VKList <StockItem>    vkList2  = new VKList <StockItem>();
            VKList <StoreProduct> products = stickersData.Products;

            if ((products != null ? products.items : (List <StoreProduct>)null) != null)
            {
                VKList <StockItem> stockItems = stickersData.StockItems;
                if ((stockItems != null ? stockItems.items : (List <StockItem>)null) != null)
                {
                    foreach (StoreProduct storeProduct in stickersData.Products.items)
                    {
                        StoreProduct product   = storeProduct;
                        StockItem    stockItem = stickersData.StockItems.items.FirstOrDefault <StockItem>((Func <StockItem, bool>)(i => i.product.id == product.id));
                        if (stockItem != null && product != null && (product.promoted != 1 || product.purchased != 1 || product.active != 0))
                        {
                            product.description = stockItem.description;
                            product.author      = stockItem.author;
                            product.photo_140   = stockItem.photo_140;
                            vkList1.items.Add(product);
                            vkList2.items.Add(stockItem);
                        }
                    }
                    vkList1.count           = vkList1.items.Count;
                    vkList2.count           = vkList2.items.Count;
                    stickersData.Products   = vkList1;
                    stickersData.StockItems = vkList2;
                }
            }
            StoreStickers recentStickers = stickersData.RecentStickers;

            if ((recentStickers != null ? recentStickers.sticker_ids : (List <int>)null) == null)
            {
                return;
            }
            stickersData.RecentStickers.sticker_ids = stickersData.RecentStickers.sticker_ids.Take <int>(32).ToList <int>();
        }