From ec45928ec01027be0254d40807a89df920d34ba3 Mon Sep 17 00:00:00 2001 From: sanao1006 Date: Wed, 29 Nov 2023 23:12:51 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20CW=E3=81=A7=E6=B3=A8=E9=87=88?= =?UTF-8?q?=E3=82=92=E7=A9=BA=E6=AC=84=E3=81=AE=E3=81=BE=E3=81=BE=E3=83=8E?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit misskeyのバージョンが11.1以上の時、「内容を隠す」で注釈が空の時にノートできなくなったため Fixed #1992 --- .../milktea/note/editor/viewmodel/NoteEditorUiState.kt | 6 +++++- .../milktea/note/editor/viewmodel/NoteEditorViewModel.kt | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorUiState.kt b/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorUiState.kt index 9dc6b251ac..140cc59499 100644 --- a/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorUiState.kt +++ b/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorUiState.kt @@ -58,11 +58,15 @@ data class NoteEditorUiState( val totalFilesCount: Int get() = this.files.size - fun checkValidate(textMaxLength: Int = 3000, maxFileCount: Int = 4): Boolean { + fun checkValidate(textMaxLength: Int = 3000, maxFileCount: Int = 4, isCwAllowBlank: Boolean = true): Boolean { if (this.files.size > maxFileCount) { return false } + if(!isCwAllowBlank) { + return false + } + if ((this.formState.text?.codePointCount(0, this.formState.text.length) ?: 0) > textMaxLength ) { diff --git a/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorViewModel.kt b/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorViewModel.kt index 7f43721cd0..2defe6aae6 100644 --- a/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorViewModel.kt +++ b/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorViewModel.kt @@ -123,6 +123,10 @@ class NoteEditorViewModel @Inject constructor( initialValue = 3000 ) + private val isCwAllowBlank = instanceInfoType.map { + it?.isCwAllowBlank ?: true + }.stateIn(viewModelScope, started = SharingStarted.Eagerly, initialValue = true) + val enableFeatures = _currentAccount.filterNotNull().map { featureEnables.enableFeatures(it.normalizedInstanceUri) @@ -242,7 +246,7 @@ class NoteEditorViewModel @Inject constructor( }.stateIn(viewModelScope + Dispatchers.IO, started = SharingStarted.Lazily, initialValue = 1500) val isPostAvailable = uiState.map { - it.checkValidate(textMaxLength = maxTextLength.value, maxFileCount = maxFileCount.value) + it.checkValidate(textMaxLength = maxTextLength.value, maxFileCount = maxFileCount.value, isCwAllowBlank = isCwAllowBlank.value) }.stateIn( viewModelScope, SharingStarted.WhileSubscribed(5_000), From f6a814b29776c65c6d680512d86fdfb3c5ea158d Mon Sep 17 00:00:00 2001 From: sanao1006 Date: Thu, 30 Nov 2023 20:12:41 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E6=96=87=E5=AD=97=E3=82=92=E5=85=A5?= =?UTF-8?q?=E5=8A=9B=E3=81=97=E3=81=A6=E3=81=84=E3=81=A6=E3=82=82=E3=83=8E?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=8C=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=83=90=E3=82=B0=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit misskeyのバージョンチェックしかしておらず、CWが空かどうかの判定をしていなかった。 これにより発生していた、テキストを入力していても文字が入力できないバグを修正する Fixed #1992 --- .../milktea/note/editor/viewmodel/NoteEditorUiState.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorUiState.kt b/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorUiState.kt index 140cc59499..a1b3cf8d61 100644 --- a/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorUiState.kt +++ b/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorUiState.kt @@ -63,7 +63,7 @@ data class NoteEditorUiState( return false } - if(!isCwAllowBlank) { + if (!isCwAllowBlank && formState.hasCw && formState.cw.isNullOrEmpty()) { return false } From 4acbf29c9d12b8d6f2475e29b978c7bb0fc17e8c Mon Sep 17 00:00:00 2001 From: sanao1006 Date: Thu, 30 Nov 2023 20:18:19 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20isCwAllowBlank=E3=82=92combine?= =?UTF-8?q?=E5=86=85=E3=81=AB=E3=81=BE=E3=81=A8=E3=82=81=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 以前までのコードでは、`isCwAllowBlank`は誰からも購読されておらずアクティブになっていなかったため無理やりEagerlyを使うことで値を取得していた。 これはリソース上効率が悪いためcombineを用いて、isPostAvailableが購読された時に一緒に購読が開始されるように修正する。 Fixed #1992 --- .../milktea/note/editor/viewmodel/NoteEditorViewModel.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorViewModel.kt b/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorViewModel.kt index 2defe6aae6..e3466e08bd 100644 --- a/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorViewModel.kt +++ b/modules/features/note/src/main/java/net/pantasystem/milktea/note/editor/viewmodel/NoteEditorViewModel.kt @@ -123,10 +123,6 @@ class NoteEditorViewModel @Inject constructor( initialValue = 3000 ) - private val isCwAllowBlank = instanceInfoType.map { - it?.isCwAllowBlank ?: true - }.stateIn(viewModelScope, started = SharingStarted.Eagerly, initialValue = true) - val enableFeatures = _currentAccount.filterNotNull().map { featureEnables.enableFeatures(it.normalizedInstanceUri) @@ -245,8 +241,9 @@ class NoteEditorViewModel @Inject constructor( logger.error("observe meta error", it) }.stateIn(viewModelScope + Dispatchers.IO, started = SharingStarted.Lazily, initialValue = 1500) - val isPostAvailable = uiState.map { - it.checkValidate(textMaxLength = maxTextLength.value, maxFileCount = maxFileCount.value, isCwAllowBlank = isCwAllowBlank.value) + val isPostAvailable = combine(instanceInfoType, uiState) { instanceInfo, uiState -> + val isCwAllowBlank = instanceInfo?.isCwAllowBlank ?: true + uiState.checkValidate(textMaxLength = maxTextLength.value, maxFileCount = maxFileCount.value, isCwAllowBlank = isCwAllowBlank) }.stateIn( viewModelScope, SharingStarted.WhileSubscribed(5_000),