Skip to content

Commit

Permalink
IOS-3152 Fix default object type selection for types from marketplace
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatovv committed Jul 22, 2024
1 parent 4b0d031 commit 15e7445
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,19 @@ final class ObjectTypeSearchViewModel: ObservableObject {
}

func didSelectType(_ type: ObjectType, section: SectionType) {
AnytypeAnalytics.instance().logTypeSearchResult()

Task {
if section == .library {
_ = try await workspaceService.installObject(spaceId: spaceId, objectId: type.id)
let newTypeDetails = try await workspaceService.installObject(spaceId: spaceId, objectId: type.id)
let newType = ObjectType(details: newTypeDetails)

toastData = ToastBarData(text: Loc.ObjectType.addedToLibrary(type.name), showSnackBar: true)

onSelect(.objectType(type: newType))
} else {
onSelect(.objectType(type: type))
}

AnytypeAnalytics.instance().logTypeSearchResult()

onSelect(.objectType(type: type))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ final class ObjectTypeProvider: ObjectTypeProviderProtocol {
}

func setDefaultObjectType(type: ObjectType, spaceId: String, route: AnalyticsDefaultObjectTypeChangeRoute) {
if !objectTypes.contains(where: { $0.id == type.id }) {
// Fix: When a new type is added via default object type menu we are lacking type data at this point.
// Save it explicitly
objectTypes.append(type)
}

defaultObjectTypes[spaceId] = type.id
AnytypeAnalytics.instance().logDefaultObjectTypeChange(type.analyticsType, route: route)
}
Expand Down

0 comments on commit 15e7445

Please sign in to comment.