Exemplo n.º 1
0
 private void OnDriveEnabledChanged()
 {
     if (App.DriveSync.SyncEnabled)
     {
         EnumerateTiltFilesWhenReady();
         OnSketchRefreshingChanged?.Invoke();
     }
     else
     {
         if (m_Sketches != null && m_Sketches.Length != 0)
         {
             foreach (var sketch in m_Sketches)
             {
                 sketch.UnloadThumbnail();
             }
             m_Sketches = null;
             OnChanged?.Invoke();
         }
     }
 }
Exemplo n.º 2
0
        private async Task EnumerateTiltFilesAsync()
        {
            m_Refreshing = true;
            OnSketchRefreshingChanged?.Invoke();
            try
            {
                // Gets all the 'Sketches' folders within each device folder on Google Drive
                List <DriveData.File> deviceFolders =
                    (await Retry(() => App.DriveAccess.GetFoldersInFolderAsync(
                                     App.GoogleUserSettings.DriveSyncFolderId, CancellationToken.None))).ToList();

                var sketchTasks = deviceFolders
                                  .Select(x => EnumerateTiltFilesForDevice(x, CancellationToken.None)).ToArray();
                await Task.WhenAll(sketchTasks);

                // If the sketch is a backup of something that came from the local machine, only show it if
                // the file is no longer present on the local machine.
                var sketchList = new List <GoogleDriveFileInfo>();
                for (int i = 0; i < deviceFolders.Count; ++i)
                {
                    if (deviceFolders[i].Id == App.DriveAccess.DeviceFolder)
                    {
                        sketchList.AddRange(sketchTasks[i].Result.Where(x => !File.Exists(x.FullPath)));
                    }
                    else
                    {
                        sketchList.AddRange(sketchTasks[i].Result);
                    }
                }
                m_Sketches = sketchList.OrderByDescending(x => x.LastModifiedTime).ToArray();
            }
            finally
            {
                await new WaitForUpdate();
                m_Refreshing = false;
                OnSketchRefreshingChanged?.Invoke();
                OnChanged?.Invoke();
            }
        }