Skip to content

Commit

Permalink
Merge pull request anyproto#379 from anyproto/ios-1591-duplicate-view…
Browse files Browse the repository at this point in the history
…-and-create-new-view-update

iOS-1591 Copy settings from the active view when create new
  • Loading branch information
joe-pusya committed Sep 28, 2023
2 parents f00af6a + b95c1c2 commit 50ac10c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ final class SetViewPickerViewModel: ObservableObject {
private func createView() {
Task { @MainActor [weak self] in
guard let self else { return }
let viewId = try await dataviewService.createView(
DataviewView.created(with: "", type: .table),
source: setDocument.details?.setOf ?? []
)
let newView = setDocument.activeView.updated(name: "", type: .table)
let source = setDocument.details?.setOf ?? []
let viewId = try await dataviewService.createView(newView, source: source)
output?.onAddButtonTap(with: viewId)
AnytypeAnalytics.instance().logAddView(
type: DataviewViewType.table.stringValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,8 @@ final class SetViewTypesPickerViewModel: ObservableObject {
private func createView() {
let name = name.isEmpty ? Loc.SetViewTypesPicker.Settings.Textfield.Placeholder.untitled : name
Task {
try await dataviewService.createView(
DataviewView.created(with: name, type: selectedType),
source: source
)
let newView = setDocument.activeView.updated(name: name, type: selectedType)
try await dataviewService.createView(newView, source: source)
AnytypeAnalytics.instance().logAddView(type: selectedType.stringValue, objectType: setDocument.analyticsType)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,6 @@ public struct DataviewView: Hashable, Identifiable {
return updated(options: newOptions)
}

public static func created(with name: String, type: DataviewViewType) -> DataviewView {
DataviewView(
id: "",
name: name,
type: type,
options: [],
sorts: [],
filters: [],
coverRelationKey: "",
hideIcon: false,
cardSize: .small,
coverFit: false,
groupRelationKey: "",
groupBackgroundColors: false,
defaultTemplateID: nil,
defaultObjectTypeID: nil
)
}

public var asMiddleware: MiddlewareDataviewView {
MiddlewareDataviewView.with {
$0.id = id
Expand Down

0 comments on commit 50ac10c

Please sign in to comment.