protected async Task ConvertToSubscribedModSet(CollectionModel collection) { //var author = await _api.GetAccount(collection.AuthorId).ConfigureAwait(false); //todo var author = new Account(collection.AuthorId); var collectionVersion = await _api.GetCollectionVersion(collection.Versions.OrderBy(x => x.Version).Last().Id).ConfigureAwait(false); var supportModding = _context.Games.FindOrThrow(collection.GameId).Modding(); var subscribedAccountId = _api.Me.Account.Id; // TODO: This can break thingsperhaps; null ref exception.... SubscribedCollection modSet; lock (_contentList.SubscribedCollections) modSet = _contentList.SubscribedCollections.FirstOrDefault( x => x.CollectionID == collection.Id && x.SubscribedAccountId == subscribedAccountId); var newCollection = modSet == null; if (newCollection) { modSet = new SubscribedCollection(collection.Id, subscribedAccountId, supportModding); } await modSet.UpdateInfoFromOnline(collection, collectionVersion, author, _contentList).ConfigureAwait(false); if (newCollection) { lock (_contentList.SubscribedCollections) _contentList.SubscribedCollections.Add(modSet); } }
async Task ConvertToPublishedModSet(CollectionModel collection) { //var author = await _api.GetAccount(collection.AuthorId).ConfigureAwait(false); var author = new Account(collection.AuthorId); // TODO: author info in collectionmodel.. var collectionVersion = await _api.GetCollectionVersion(collection.Versions.Last().Id).ConfigureAwait(false); var supportModding = _context.Games.FindOrThrow(collection.GameId).Modding(); var accountId = _api.Me.Account.Id; CustomCollection modSet; lock (_contentList.CustomCollections) { modSet = _contentList.CustomCollections.FirstOrDefault( x => x.PublishedId == collection.Id && x.PublishedAccountId == accountId); } var newCollection = modSet == null; if (newCollection) { modSet = new CustomCollection(collection.Id, supportModding); } await modSet.UpdateInfoFromOnline(collection, collectionVersion, author, _contentList).ConfigureAwait(false); if (newCollection) { lock (_contentList.CustomCollections) _contentList.CustomCollections.Add(modSet); } }