diff --git a/api/src/main/java/com/readrops/api/services/nextcloudnews/NewNextcloudNewsService.kt b/api/src/main/java/com/readrops/api/services/nextcloudnews/NewNextcloudNewsService.kt index 5b725f5a..29813af1 100644 --- a/api/src/main/java/com/readrops/api/services/nextcloudnews/NewNextcloudNewsService.kt +++ b/api/src/main/java/com/readrops/api/services/nextcloudnews/NewNextcloudNewsService.kt @@ -52,10 +52,10 @@ interface NewNextcloudNewsService { @DELETE("feeds/{feedId}") suspend fun deleteFeed(@Path("feedId") feedId: Int) - @PUT("feeds/{feedId}/move") + @POST("feeds/{feedId}/move") suspend fun changeFeedFolder(@Path("feedId") feedId: Int, @Body folderIdMap: Map) - @PUT("feeds/{feedId}/rename") + @POST("feeds/{feedId}/rename") suspend fun renameFeed(@Path("feedId") feedId: Int, @Body feedTitleMap: Map) @POST("folders") diff --git a/app/src/main/java/com/readrops/app/repositories/NextcloudNewsRepository.kt b/app/src/main/java/com/readrops/app/repositories/NextcloudNewsRepository.kt index 4c8defc5..9f6c4d32 100644 --- a/app/src/main/java/com/readrops/app/repositories/NextcloudNewsRepository.kt +++ b/app/src/main/java/com/readrops/app/repositories/NextcloudNewsRepository.kt @@ -12,6 +12,11 @@ import com.readrops.db.entities.Feed import com.readrops.db.entities.Folder import com.readrops.db.entities.Item import com.readrops.db.entities.account.Account +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.withContext import org.joda.time.DateTime import org.koin.core.component.KoinComponent import org.koin.core.component.get @@ -19,7 +24,8 @@ import org.koin.core.component.get class NextcloudNewsRepository( database: Database, account: Account, - private val dataSource: NewNextcloudNewsDataSource + private val dataSource: NewNextcloudNewsDataSource, + private val dispatcher: CoroutineDispatcher = Dispatchers.IO ) : BaseRepository(database, account), KoinComponent { override suspend fun login(account: Account) { @@ -95,12 +101,14 @@ class NextcloudNewsRepository( return errors } - override suspend fun updateFeed(feed: Feed) { + override suspend fun updateFeed(feed: Feed) = withContext(dispatcher) { val folder = if (feed.folderId != null) database.folderDao().select(feed.folderId!!) else null - dataSource.renameFeed(feed.name!!, feed.remoteId!!.toInt()) - dataSource.changeFeedFolder(folder?.remoteId?.toInt(), feed.remoteId!!.toInt()) + listOf( + async { dataSource.renameFeed(feed.name!!, feed.remoteId!!.toInt()) }, + async { dataSource.changeFeedFolder(folder?.remoteId?.toInt(), feed.remoteId!!.toInt()) } + ).awaitAll() super.updateFeed(feed) }