summary refs log tree commit diff stats
path: root/widgets
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2019-07-17 21:49:28 +0100
committerDrew DeVault <sir@cmpwn.com>2019-07-17 17:33:31 -0400
commit4a5aa7dc27cd1b48db4d6211f74e909de1aa558d (patch)
treebb9fc9541bd3ee044e082b3e134cbb0cba49f33c /widgets
parent1d1fe7c7ef42a4d85121f7b5a14376743876f080 (diff)
downloadaerc-4a5aa7dc27cd1b48db4d6211f74e909de1aa558d.tar.gz
Remove passing of showHeaders explicitly
Where it is needed the configs are already available so just extract the
value from these.
Diffstat (limited to 'widgets')
-rw-r--r--widgets/msgviewer.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 7f24869..1f0b0e4 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -56,7 +56,7 @@ func NewMessageViewer(acct *AccountView, conf *config.AercConfig,
 
 	switcher := &PartSwitcher{}
 	switcher.selected = -1
-	err := createSwitcher(switcher, conf, store, msg, conf.Viewer.ShowHeaders)
+	err := createSwitcher(switcher, conf, store, msg)
 	if err != nil {
 		return &MessageViewer{
 			err:  err,
@@ -135,7 +135,7 @@ func fmtHeader(msg *models.MessageInfo, header string) string {
 
 func enumerateParts(conf *config.AercConfig, store *lib.MessageStore,
 	msg *models.MessageInfo, body *models.BodyStructure,
-	showHeaders bool, index []int) ([]*PartViewer, error) {
+	index []int) ([]*PartViewer, error) {
 
 	var parts []*PartViewer
 	for i, part := range body.Parts {
@@ -145,14 +145,14 @@ func enumerateParts(conf *config.AercConfig, store *lib.MessageStore,
 			pv := &PartViewer{part: part}
 			parts = append(parts, pv)
 			subParts, err := enumerateParts(
-				conf, store, msg, part, showHeaders, curindex)
+				conf, store, msg, part, curindex)
 			if err != nil {
 				return nil, err
 			}
 			parts = append(parts, subParts...)
 			continue
 		}
-		pv, err := NewPartViewer(conf, store, msg, part, showHeaders, curindex)
+		pv, err := NewPartViewer(conf, store, msg, part, curindex)
 		if err != nil {
 			return nil, err
 		}
@@ -162,14 +162,13 @@ func enumerateParts(conf *config.AercConfig, store *lib.MessageStore,
 }
 
 func createSwitcher(switcher *PartSwitcher, conf *config.AercConfig,
-	store *lib.MessageStore, msg *models.MessageInfo, showHeaders bool) error {
+	store *lib.MessageStore, msg *models.MessageInfo) error {
 	var err error
-	switcher.showHeaders = showHeaders
+	switcher.showHeaders = conf.Viewer.ShowHeaders
 
 	if len(msg.BodyStructure.Parts) == 0 {
 		switcher.selected = 0
-		pv, err := NewPartViewer(conf, store, msg, msg.BodyStructure,
-			showHeaders, []int{1})
+		pv, err := NewPartViewer(conf, store, msg, msg.BodyStructure, []int{1})
 		if err != nil {
 			return err
 		}
@@ -179,7 +178,7 @@ func createSwitcher(switcher *PartSwitcher, conf *config.AercConfig,
 		})
 	} else {
 		switcher.parts, err = enumerateParts(conf, store,
-			msg, msg.BodyStructure, showHeaders, []int{})
+			msg, msg.BodyStructure, []int{})
 		if err != nil {
 			return err
 		}
@@ -244,8 +243,9 @@ func (mv *MessageViewer) SelectedMessage() (*models.MessageInfo, error) {
 
 func (mv *MessageViewer) ToggleHeaders() {
 	switcher := mv.switcher
+	mv.conf.Viewer.ShowHeaders = !mv.conf.Viewer.ShowHeaders
 	err := createSwitcher(
-		switcher, mv.conf, mv.store, mv.msg, !switcher.showHeaders)
+		switcher, mv.conf, mv.store, mv.msg)
 	if err != nil {
 		mv.acct.Logger().Printf(
 			"warning: error during create switcher - %v", err)
@@ -360,7 +360,7 @@ type PartViewer struct {
 
 func NewPartViewer(conf *config.AercConfig,
 	store *lib.MessageStore, msg *models.MessageInfo,
-	part *models.BodyStructure, showHeaders bool,
+	part *models.BodyStructure,
 	index []int) (*PartViewer, error) {
 
 	var (
@@ -424,7 +424,7 @@ func NewPartViewer(conf *config.AercConfig,
 		pager:       pager,
 		pagerin:     pagerin,
 		part:        part,
-		showHeaders: showHeaders,
+		showHeaders: conf.Viewer.ShowHeaders,
 		sink:        pipe,
 		store:       store,
 		term:        term,
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588