public IEnumerator LoadAndDisplayDocuments() { Workspace.StopPolling(); /* * var e = new DocumentsGetElementListResponse200Elements(); * e.Id = "80502b44d24b6879f2adbfc9"; * e.ElementType = "PARTSTUDIO"; * Workspace.Show("03d0656aa06f0989afa26a75", "811491828a13083e1873783f", e); */ ShowProgress("Retrieving documents..."); if (_firstload) { yield return(OnshapeOAuth.Instance.GetTokens()); } if (string.IsNullOrEmpty(ApiClient.Instance.AccessToken)) { LogError("Unable to retrieve Access tocken"); ShowProgress("Failed to authenticate, try again..."); LocalServer.Listen(); yield break; } _firstload = false; var docRequest = ApiClient.Instance.Documents.GetDocuments(null, null, null, null, "modifiedAt", "desc", null, 8); yield return(docRequest.CallApi()); if (!docRequest.OK) { LogError("Unable to retrieve document list"); yield break; } foreach (var doc in docRequest.Response.Items) { if (doc.Thumbnail.Sizes.Count == 0) { continue; } var url = doc.Thumbnail.Sizes[0].Href; var imgReq = new ImageRequest(url, Method.GET, new Dictionary <string, string>(), null, true); yield return(imgReq.CallApi()); if (imgReq.Image == null) { LogError("Unable to get image : " + url); } else { doc.Thumbnail.Image = imgReq.Image; } } HideProgress(); MenuDocument.RefreshDocumentList(docRequest.Response); }