File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
WordPress/Classes/ViewRelated Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -40,13 +40,12 @@ final class CommentCreateViewModel {
4040 /// Create a reply to the given comment.
4141 init ( replyingTo comment: Comment , save: @escaping ( String ) async throws -> Void ) {
4242 let siteID = comment. associatedSiteID ?? 0
43- wpAssert ( siteID != 0 , " missing required parameter siteID " )
4443
4544 self . siteID = siteID
4645 self . replyToComment = comment
4746 self . _save = save
4847
49- self . suggestionsViewModel = SuggestionsListViewModel . make ( siteID : siteID )
48+ self . suggestionsViewModel = comment . blog . flatMap { SuggestionsListViewModel . make ( blog : $0 ) }
5049 self . suggestionsViewModel? . enableProminentSuggestions (
5150 postAuthorID: comment. post? . authorID,
5251 commentAuthorID: comment. commentID as NSNumber
Original file line number Diff line number Diff line change @@ -69,8 +69,17 @@ import CoreData
6969 service: SuggestionService = SuggestionService . shared,
7070 context: NSManagedObjectContext = ContextManager . shared. mainContext
7171 ) -> SuggestionsListViewModel ? {
72- guard let blog = Blog . lookup ( withID: siteID, in: context) ,
73- service. shouldShowSuggestions ( for: blog) else {
72+ guard siteID. intValue != 0 , let blog = Blog . lookup ( withID: siteID, in: context) else {
73+ return nil
74+ }
75+ return make ( blog: blog, service: service)
76+ }
77+
78+ static func make(
79+ blog: Blog ,
80+ service: SuggestionService = SuggestionService . shared
81+ ) -> SuggestionsListViewModel ? {
82+ guard service. shouldShowSuggestions ( for: blog) else {
7483 return nil
7584 }
7685 return SuggestionsListViewModel ( blog: blog)
You can’t perform that action at this time.
0 commit comments