Skip to content

Commit ac390b2

Browse files
committed
Fix importing notes that exceed max character limit
1 parent adba26f commit ac390b2

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

app/src/main/java/com/philkes/notallyx/utils/backup/ImportExtensions.kt

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidx.documentfile.provider.DocumentFile
1515
import androidx.lifecycle.MutableLiveData
1616
import com.philkes.notallyx.R
1717
import com.philkes.notallyx.data.NotallyDatabase
18+
import com.philkes.notallyx.data.dao.BaseNoteDao.Companion.MAX_BODY_CHAR_LENGTH
1819
import com.philkes.notallyx.data.imports.ImportProgress
1920
import com.philkes.notallyx.data.imports.ImportStage
2021
import com.philkes.notallyx.data.model.Audio
@@ -121,8 +122,28 @@ suspend fun ContextWrapper.importZip(
121122
SQLiteDatabase.openDatabase(dbFile.path, null, SQLiteDatabase.OPEN_READONLY)
122123

123124
val labelCursor = database.query("Label", null, null, null, null, null, null)
124-
val baseNoteCursor = database.query("BaseNote", null, null, null, null, null, null)
125-
125+
val columns =
126+
arrayOf(
127+
"id",
128+
"type",
129+
"folder",
130+
"color",
131+
"title",
132+
"pinned",
133+
"timestamp",
134+
"modifiedTimestamp",
135+
"labels",
136+
"SUBSTR(body, 1, ${MAX_BODY_CHAR_LENGTH}) AS body",
137+
"spans",
138+
"items",
139+
"images",
140+
"files",
141+
"audios",
142+
"reminders",
143+
"viewMode",
144+
)
145+
val baseNoteCursor =
146+
database.query("BaseNote", columns, null, null, null, null, null)
126147
val labels = labelCursor.toList { cursor -> cursor.toLabel() }
127148

128149
var total = baseNoteCursor.count
@@ -137,7 +158,6 @@ suspend fun ContextWrapper.importZip(
137158
importingBackup?.postValue(ImportProgress(counter++, total))
138159
baseNote
139160
}
140-
141161
delay(1000)
142162

143163
total =

0 commit comments

Comments
 (0)