<commit_before>import {invokeLifecycle} from './lifecycle';

export class NotificationController {
  constructor(renderer: NotificationRenderer, settings: any) {
    this.renderer = renderer;
    this.settings = settings;
  }

  close() {
    clearTimeout(this.timer);

    return invokeLifecycle(this.viewModel, 'canDeactivate')
      .then(canDeactivate => {
        if (canDeactivate) {
          invokeLifecycle(this.viewModel, 'deactivate')
            .then(() => {
              return this.renderer.hideNotification(this);
            })
            .then(() => {
              return this.renderer.destroyNotificationHost(this);
            })
            .then(() => {
              this.controller.unbind();
            });
        }
      });
  }
}<commit_msg>fix(controller): fix creating multiple close promises<commit_after>import {invokeLifecycle} from './lifecycle';

export class NotificationController {
  constructor(renderer: NotificationRenderer, settings: any) {
    this.renderer = renderer;
    this.settings = settings;
  }

  close() {
    if (this.closePromise) {
      return this.closePromise;
    }
    clearTimeout(this.timer);
    return this.closePromise = invokeLifecycle(this.viewModel, 'canDeactivate')
      .then(canDeactivate => {
        if (canDeactivate) {
          invokeLifecycle(this.viewModel, 'deactivate')
            .then(() => {
              return this.renderer.hideNotification(this);
            })
            .then(() => {
              return this.renderer.destroyNotificationHost(this);
            })
            .then(() => {
              this.controller.unbind();
            });
        }
      });
  }
}
{'fraction_non_alphanumeric': 0.12694610778443113, 'fraction_numerical': 0.0, 'mean_word_length': 2.1528301886792454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5262200', 'n_tokens_mistral': 442, 'n_tokens_neox': 441, 'n_words': 76}