Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OFF-1457 #7

Closed
wants to merge 3 commits into from
Closed

OFF-1457 #7

wants to merge 3 commits into from

Conversation

MishelleBit
Copy link

No description provided.

customDataInterface := decision.Contents[0].Data.CustomData
customDataMap, ok := customDataInterface.(map[string]interface{})
var defaultStandardHeight int64 = 2400
var defaultCompactHeight int64 = 600

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use const for constants and place them at the beginning of the file

Comment on lines 224 to 225
var defaultStandardHeight int64 = 2400
var defaultCompactHeight int64 = 600

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should move this to the top of the file with all the other consts

Comment on lines 227 to 248
if flippExtParams.Options.StartCompact {
if ok { // check if customDataMap exists and startCompact is true
if height, exists := customDataMap["compactHeight"].(int64); exists {
bid.H = height
} else {
bid.H = defaultCompactHeight
}
} else {
bid.H = defaultCompactHeight
}
} else { // startCompact is false
if ok { // customDataMap exists
if height, exists := customDataMap["standardHeight"].(int64); exists {
bid.H = height
} else {
bid.H = defaultStandardHeight
}
} else {
bid.H = defaultStandardHeight
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify this a little further by doing

if flippExtParams.Options.StartCompact {
	defaultHeight = defaultCompactHeight
} else {
	defaultHeight = defaultStandardHeight
}

bid.H = defaultHeight

if ok { 
	if height, exists := customDataMap[flippExtParams.Options.StartCompact ? "compactHeight" : "standardHeight"].(int64); exists {
		bid.H = height
	}
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	if height, exists := customDataMap[flippExtParams.Options.StartCompact ? "compactHeight" : "standardHeight"].(int64); exists {

I get an error for the ? operator, saying expected ']', found 'ILLEGAL'syntax

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry 🤦‍♂️ you can do this instead

if flippExtParams.Options.StartCompact {
	defaultHeight = 600 // Default compact height
} else {
	defaultHeight = 2400 // Default standard height
}

// Set default height first
bid.H = defaultHeight

if ok { // customDataMap exists
	var key string
	if flippExtParams.Options.StartCompact {
		key = "compactHeight"
	} else {
		key = "standardHeight"
	}

	if height, exists := customDataMap[key].(int64); exists {
		bid.H = height
	}
}

@MishelleBit MishelleBit deleted the OFF-1457 branch September 19, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants