mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-03 23:58:55 +01:00 
			
		
		
		
	Replace history query with actual upsert
This commit is contained in:
		@@ -93,22 +93,12 @@ class HistoryRepositoryImpl(
 | 
			
		||||
 | 
			
		||||
    override suspend fun upsertHistory(historyUpdate: HistoryUpdate) {
 | 
			
		||||
        try {
 | 
			
		||||
            try {
 | 
			
		||||
                handler.await {
 | 
			
		||||
                    historyQueries.insert(
 | 
			
		||||
                        historyUpdate.chapterId,
 | 
			
		||||
                        historyUpdate.readAt,
 | 
			
		||||
                        historyUpdate.sessionReadDuration,
 | 
			
		||||
                    )
 | 
			
		||||
                }
 | 
			
		||||
            } catch (e: Exception) {
 | 
			
		||||
                handler.await {
 | 
			
		||||
                    historyQueries.update(
 | 
			
		||||
                        historyUpdate.readAt,
 | 
			
		||||
                        historyUpdate.sessionReadDuration,
 | 
			
		||||
                        historyUpdate.chapterId,
 | 
			
		||||
                    )
 | 
			
		||||
                }
 | 
			
		||||
            handler.await {
 | 
			
		||||
                historyQueries.upsert(
 | 
			
		||||
                    historyUpdate.chapterId,
 | 
			
		||||
                    historyUpdate.readAt,
 | 
			
		||||
                    historyUpdate.sessionReadDuration,
 | 
			
		||||
                )
 | 
			
		||||
            }
 | 
			
		||||
        } catch (e: Exception) {
 | 
			
		||||
            logcat(LogPriority.ERROR, throwable = e)
 | 
			
		||||
 
 | 
			
		||||
@@ -30,16 +30,6 @@ interface HistoryQueries : DbProvider {
 | 
			
		||||
        )
 | 
			
		||||
        .prepare()
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Updates the history last read.
 | 
			
		||||
     * Inserts history object if not yet in database
 | 
			
		||||
     * @param history history object
 | 
			
		||||
     */
 | 
			
		||||
    fun upsertHistoryLastRead(history: History) = db.put()
 | 
			
		||||
        .`object`(history)
 | 
			
		||||
        .withPutResolver(HistoryUpsertResolver())
 | 
			
		||||
        .prepare()
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Updates the history last read.
 | 
			
		||||
     * Inserts history object if not yet in database
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user