Exemplo n.º 1
0
        protected override bool IsVisible(IPackageVersion version)
        {
            if (version?.HasTag(PackageTag.Downloadable) != true)
            {
                return(false);
            }

            var localInfo = m_AssetStoreCache.GetLocalInfo(version.packageUniqueId);
            var operation = m_AssetStoreDownloadManager.GetDownloadOperation(version.packageUniqueId);

            return(localInfo?.canUpdate == false &&
                   (operation == null || operation.state == DownloadState.DownloadRequested || !operation.isProgressVisible));
        }
Exemplo n.º 2
0
        private void BindItem(VisualElement item, int index)
        {
            var packageItem = item as PackageItem;

            if (packageItem == null)
            {
                return;
            }

            var visualState = GetVisualStateByIndex(index);

            if (!string.IsNullOrEmpty(visualState?.packageUniqueId))
            {
                var package = m_PackageDatabase.GetPackage(visualState.packageUniqueId);
                packageItem.SetPackageAndVisualState(package, visualState);

                m_PackageItemsLookup[visualState.packageUniqueId] = packageItem;

                if (package is PlaceholderPackage)
                {
                    m_AssetStoreCallQueue.AddToFetchDetailsQueue(visualState.packageUniqueId);
                }

                var localInfo = m_AssetStoreCache.GetLocalInfo(visualState.packageUniqueId);
                if (localInfo?.updateInfoFetched == false)
                {
                    m_AssetStoreCallQueue.InsertToCheckUpdateQueue(visualState.packageUniqueId);
                }
            }
        }
Exemplo n.º 3
0
        private void FetchInternal(long productId, AssetStorePurchaseInfo purchaseInfo)
        {
            RefreshLocalInfos();

            var id = productId.ToString();

            if (m_AssetStoreCache.GetLocalInfo(id)?.updateInfoFetched == false)
            {
                CheckUpdate(new[] { id });
            }

            // create a placeholder before fetching data from the cloud for the first time
            if (m_AssetStoreCache.GetProductInfo(id) == null)
            {
                onPackagesChanged?.Invoke(new[] { new PlaceholderPackage(id, purchaseInfo?.displayName ?? string.Empty, PackageType.AssetStore, PackageTag.Downloadable, PackageProgress.Refreshing) });
            }

            FetchDetails(new[] { productId });
            onProductFetched?.Invoke(productId);
        }
        private void CheckUpdateFromStack()
        {
            if (!m_UnityConnect.isUserLoggedIn || m_CheckUpdateInProgress || !m_CheckUpdateStack.Any())
            {
                return;
            }

            var checkUpdateList = new List <string>(k_CheckUpdateChunkSize);

            while (m_CheckUpdateStack.Any() && checkUpdateList.Count < k_CheckUpdateChunkSize)
            {
                var id = m_CheckUpdateStack.Pop();
                if (m_ForceCheckUpdateLookup.TryGetValue(id, out var forceCheck))
                {
                    if (forceCheck || m_AssetStoreCache.GetLocalInfo(id)?.updateInfoFetched == false)
                    {
                        checkUpdateList.Add(id);
                    }
                    m_ForceCheckUpdateLookup.Remove(id);
                }
            }

            if (checkUpdateList.Any())
            {
                m_CheckUpdateInProgress = true;
                m_AssetStoreClient.CheckUpdate(checkUpdateList, () =>
                {
                    m_CheckUpdateInProgress = false;
                    onCheckUpdateProgress?.Invoke();

                    if (m_RefreshAfterCheckUpdates && !m_CheckUpdateStack.Any())
                    {
                        var page = m_PageManager.GetCurrentPage();
                        if (page.filters.updateAvailableOnly)
                        {
                            m_PageManager.Refresh();
                        }
                        m_RefreshAfterCheckUpdates = false;
                    }
                });
            }
            onCheckUpdateProgress?.Invoke();
        }
Exemplo n.º 5
0
        public virtual void Download(IPackage package)
        {
            var packageId = package?.uniqueId;

            if (string.IsNullOrEmpty(packageId))
            {
                return;
            }

            var operation = GetDownloadOperation(packageId);

            if (operation?.isInProgress ?? false)
            {
                return;
            }

            var localInfo = m_AssetStoreCache.GetLocalInfo(packageId);

            operation = new AssetStoreDownloadOperation(m_AssetStoreUtils, m_AssetStoreRestAPI, m_AssetStoreCachePathProxy, packageId, localInfo?.packagePath);
            SetupDownloadOperation(operation);
            operation.Download(false);
        }
Exemplo n.º 6
0
        public virtual void GetProductUpdateDetail(IEnumerable <string> productIds, Action <Dictionary <string, object> > doneCallbackAction)
        {
            if (productIds?.Any() != true)
            {
                doneCallbackAction?.Invoke(new Dictionary <string, object>());
                return;
            }

            var localInfos = new List <AssetStoreLocalInfo>();

            foreach (var productId in productIds)
            {
                var localInfo = m_AssetStoreCache.GetLocalInfo(productId);
                if (localInfo?.updateInfoFetched == false)
                {
                    localInfos.Add(localInfo);
                }
            }
            var localInfosJsonData = Json.Serialize(localInfos.Select(info => info?.ToDictionary() ?? new Dictionary <string, string>()).ToList());

            HandleHttpRequest(() => m_HttpClientFactory.PostASyncHTTPClient($"{host}{k_UpdateInfoUri}", localInfosJsonData),
                              result =>
            {
                var ret = result["result"] as Dictionary <string, object>;
                doneCallbackAction?.Invoke(ret);
            },
                              error =>
            {
                var ret = new Dictionary <string, object>
                {
                    ["errorMessage"] = error.message,
                    ["errorCode"]    = error.operationErrorCode
                };
                doneCallbackAction?.Invoke(ret);
            });
        }