Commit 949911d5 authored by Francisco Jordano's avatar Francisco Jordano
Browse files

Detecting from settings window when the import from fb happened

parent 3531dca0
Loading
Loading
Loading
Loading
+12 −4
Changes for apps/communications/contacts/js/contacts_settings.js: 12 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -57,15 +57,23 @@ contacts.Settings = (function() {
      onSimImport);

    fbImportLink = document.querySelector('[data-l10n-id="importFb"]');
    fb.utils.getImportChecked(function fbImported(value) {
    document.addEventListener('fb_imported', function onImported(evt) {
      // We just received an event sayin we imported the contacts
      checkFbImported(true);
    });
    fb.utils.getImportChecked(checkFbImported);
    fbImportLink.addEventListener('click', onFbImport);
  };

  // Callback that will modify the ui depending if we imported or not
  // contacts from FB
  var checkFbImported = function checkFbImportedCb(value) {
    fbImportedValue = value;
    if (fbImportedValue) {
      fbImportLink.innerHTML = 'Facebook';
      fbAddUnlinkOption();
    }
    });
    fbImportLink.addEventListener('click', onFbImport);
  };
  }

  // Insert the dom necessary to unlink your FB contacts
  var fbAddUnlinkOption = function fbUnlinkOption() {
+2 −0
Changes for apps/communications/contacts/js/fb/fb_import.js: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -361,6 +361,8 @@ if (typeof fb.importer === 'undefined') {
     */
    UI.importAll = function(e) {
      if (Object.keys(selectedContacts).length > 0) {
        fb.utils.setImportChecked(true);
        
        Importer.importAll(function() {

          document.body.dataset.state = '';
+5 −0
Changes for apps/communications/contacts/js/fb_extensions.js: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -123,6 +123,11 @@ if (typeof Contacts.extFb === 'undefined') {

      switch (data.type) {
        case 'window_close':
          // Notify observers that the import happened
          var event = new CustomEvent('fb_imported', 
            {'detail' : true }
          );
          document.dispatchEvent(event)
          close(data.from);
          if (data.from === 'import') {
            contacts.List.load();