mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
delete event types created at caldav sync, if the calendar is unsynced
This commit is contained in:
@@ -70,7 +70,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
if (config.primaryColor != mStoredPrimaryColor) {
|
if (config.primaryColor != mStoredPrimaryColor) {
|
||||||
dbHelper.getEventTypes {
|
dbHelper.getEventTypes {
|
||||||
if (it.filter { it.caldavCalendarId == 0 }.size == 1) {
|
if (it.filter { it.caldavCalendarId == 0 }.size == 1) {
|
||||||
val eventType = it[0]
|
val eventType = it.first { it.caldavCalendarId == 0 }
|
||||||
eventType.color = config.primaryColor
|
eventType.color = config.primaryColor
|
||||||
dbHelper.updateEventType(eventType)
|
dbHelper.updateEventType(eventType)
|
||||||
}
|
}
|
||||||
@@ -156,6 +156,8 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
|
|
||||||
oldCalendarIds.filter { !newCalendarIds.contains(it) }.forEach {
|
oldCalendarIds.filter { !newCalendarIds.contains(it) }.forEach {
|
||||||
CalDAVEventsHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
|
CalDAVEventsHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
|
||||||
|
val eventId = dbHelper.getEventTypeIdWithCalDAVCalendarId(it.toInt())
|
||||||
|
dbHelper.deleteEventTypes(arrayListOf(eventId), true) {}
|
||||||
}
|
}
|
||||||
}).start()
|
}).start()
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@ import com.simplemobiletools.commons.extensions.getLongValue
|
|||||||
import com.simplemobiletools.commons.extensions.getStringValue
|
import com.simplemobiletools.commons.extensions.getStringValue
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
||||||
private val MAIN_TABLE_NAME = "events"
|
private val MAIN_TABLE_NAME = "events"
|
||||||
|
Reference in New Issue
Block a user