From 31beb03a039cc61a1dd1bb3e6a8eaded63c601f6 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 90233ba490..46c560c2d7 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift @@ -639,26 +639,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) } }