Thin the app's comments
The same pass the server had, on the Kotlin side: comments restating what the code says are gone, and the ones recording a measurement, a constraint or an incident are kept but cut to a few lines each. 6540 comment lines to 5674, and 920 lines off the app. Two doc comments had drifted onto the item above the one they describe -- `contextAfter`'s onto `sessionWorking` in Events.kt, and `UsageMonitor`'s equivalent on the server was fixed in the previous commit. Each is back on its own item, which is the only non-comment line this diff moves. The comments are reflowed to the column limit at their own indentation: several were written wide, and ktfmt re-wrapped them into lines holding a single orphan word. `/tmp` script, not kept -- ktfmt is idempotent over the result, which is the check. Left alone deliberately: this codebase's remaining comment density is high because the comments carry things the code cannot say -- what a null means, what a number was measured against, which bug a guard exists for. Of the 238 one-line doc comments in the app, five were pure restatement of the name and were removed; the rest each say something the signature does not. ktfmtFormat, compileDebugKotlin, lintDebug and testDebugUnitTest pass; cargo test (127), clippy --all-targets and fmt still clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
79682f03a7
commit
edc39c7371
68 files changed
+2077
-2997
No files matched your search
@@ -10,12 +10,11 @@ private const val DRAFTS = "session-drafts"
|
||||
*
|
||||
* On this device rather than on the backend, which is where this app otherwise keeps state so that
|
||||
* every device sees it. A draft is the case that rule is not about: it is the contents of a text
|
||||
* box on the phone somebody is holding, written on every keystroke, and half a sentence surfacing
|
||||
* on another device would be a surprise rather than a convenience. What has been *sent* is the
|
||||
* server's, and that is the part which has to outlive this phone.
|
||||
* box on the phone somebody is holding, and half a sentence surfacing on another device would be a
|
||||
* surprise. What has been *sent* is the server's.
|
||||
*
|
||||
* Kept per session id, because the thing being typed belongs to the conversation it is aimed at:
|
||||
* one shared box would hand a message meant for one session to whichever was opened next.
|
||||
* Kept per session id: one shared box would hand a message meant for one session to whichever was
|
||||
* opened next.
|
||||
*/
|
||||
fun loadDraft(context: Context, sessionId: String): String =
|
||||
context.getSharedPreferences(DRAFTS, Context.MODE_PRIVATE).getString(sessionId, "").orEmpty()
|
||||
@@ -23,11 +22,9 @@ fun loadDraft(context: Context, sessionId: String): String =
|
||||
/**
|
||||
* Records [text] as the draft for [sessionId], or forgets it when there is nothing left to keep.
|
||||
*
|
||||
* The path out is emptying the box, which is what sending does -- so a sent message removes its own
|
||||
* entry and nothing accumulates for a session in ordinary use. A session *deleted* while it held a
|
||||
* draft does leave its key behind: pruning those means a pass over the live session list, which
|
||||
* this file would otherwise have no reason to know about, and the residue is a few bytes per
|
||||
* session ever abandoned mid-sentence. That is a trade rather than an oversight.
|
||||
* The path out is emptying the box, which is what sending does. A session *deleted* while it held a
|
||||
* draft does leave its key behind: pruning those means a pass over the live session list, and the
|
||||
* residue is a few bytes per session ever abandoned mid-sentence.
|
||||
*/
|
||||
fun saveDraft(context: Context, sessionId: String, text: String) {
|
||||
context.getSharedPreferences(DRAFTS, Context.MODE_PRIVATE).edit {
|
||||
|
||||
Reference in new issue
Block a user