From e15f8942d4dd6e2641c8c135289a21021e523f9a Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Mon, 20 Feb 2023 21:48:05 +0100 Subject: [PATCH] Add fix for #940 (IOS-2) --- .../ComposeContentViewModel.swift | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift index a9acdfb30e..a42779e4db 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift @@ -641,26 +641,24 @@ extension ComposeContentViewModel { // save language to recent languages if let settings = context.settingService.currentSetting.value { - Task.detached(priority: .background) { [language] in - try await settings.managedObjectContext?.performChanges { - settings.recentLanguages = [language] + settings.recentLanguages.filter { $0 != language } - } + settings.managedObjectContext?.performAndWait { + settings.recentLanguages = [language] + settings.recentLanguages.filter { $0 != language } } } return MastodonEditStatusPublisher(statusID: status.id, - author: author, - isContentWarningComposing: isContentWarningActive, - contentWarning: contentWarning, - content: content, - isMediaSensitive: isContentWarningActive, - attachmentViewModels: attachmentViewModels, - isPollComposing: isPollActive, - pollOptions: pollOptions, - pollExpireConfigurationOption: pollExpireConfigurationOption, - pollMultipleConfigurationOption: pollMultipleConfigurationOption, - visibility: visibility, - language: language) + author: author, + isContentWarningComposing: isContentWarningActive, + contentWarning: contentWarning, + content: content, + isMediaSensitive: isContentWarningActive, + attachmentViewModels: attachmentViewModels, + isPollComposing: isPollActive, + pollOptions: pollOptions, + pollExpireConfigurationOption: pollExpireConfigurationOption, + pollMultipleConfigurationOption: pollMultipleConfigurationOption, + visibility: visibility, + language: language) } }