<commit_before>Ti.include('/util.js');
Ti.include('/data.js');
Ti.include('/messageHandler.js');
(function (window) {
  var newMsgButton, debugButton;

  window.barColor = '#123';

  newMsgButton = Ti.UI.createButton({
    title: "New MSG"
  });
  newMsgButton.addEventListener('click', function () {
    Ti.UI.createWindow({ url: 'new_message.js', modal: true }).open();
  });
  window.addEventListener('focus', function () {
    window.rightNavButton = Util.isEmptyObject(Data.getUserClubs()) ? undefined : newMsgButton;
  });

  //table = Util.createSimpleDataTable()
  debugButton = Ti.UI.createButton({
  	title: 'get inbox',
  	top: 20
  });
  debugButton.addEventListener('click', function(){
  	Messages.showInbox(function(messages){
  		var subjectArray = [];
  		for(var i =0;i<messages.length;i++){
  			subjectArray.push(messages[i].subject);
  		}
  		Ti.API.info(messages);
  		table = Util.createSimpleDataTable(subjectArray, {'row':{height:40}});
  		window.add(table);
  	}) 	
  });
  window.add(debugButton);

}).call(Ti.UI.currentWindow, Ti.UI.currentWindow);<commit_msg>Moved debug button to navbar under the name 'refreshBtn'. Table auto-refreshes on window focus. Clicking a message shows the view_message window.<commit_after>Ti.include('/util.js');
Ti.include('/data.js');
Ti.include('/messageHandler.js');
(function (window) {
  var newMsgButton, refreshBtn, table, refresh, allMessages;

  window.barColor = '#123';

  newMsgButton = Ti.UI.createButton({
    title: "New MSG"
  });
  newMsgButton.addEventListener('click', function () {
    Ti.UI.createWindow({ url: 'new_message.js', modal: true }).open();
  });
  window.addEventListener('focus', function () {
    window.rightNavButton = Util.isEmptyObject(Data.getUserClubs()) ? undefined : newMsgButton;
    refresh();
  });
  
  table = Ti.UI.createTableView();
  window.add(table);
  table.addEventListener('click', function (event) {
    if (!(allMessages[event.index])) return;
    var msgData = allMessages[event.index];
    var viewMsg = Ti.UI.createWindow({
      url: '/windows/view_message.js',
      opacity: 0
    });
    viewMsg.addEventListener('open', function () {
      viewMsg.fireEvent('data', {
        data: msgData
      });
    });
    viewMsg.open();
  });
  
  refresh = function () {
    Messages.showInbox(function (messages) {
      allMessages = messages;
      table.data = Util.foreach(messages, function (_, item) {
        return Ti.UI.createTableViewRow({
          title: item.subject,
          height: 40
        });
      });
    });
  };
  
  refreshBtn = (window.leftNavButton = Ti.UI.createButton({
    title: 'Refresh'
  }));
  refreshBtn.addEventListener('click', function () {
    refresh(); 	
  });

}).call(Ti.UI.currentWindow, Ti.UI.currentWindow);
{'fraction_non_alphanumeric': 0.16648648648648648, 'fraction_numerical': 0.005045045045045045, 'mean_word_length': 3.6266666666666665, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '639566', 'n_tokens_mistral': 903, 'n_tokens_neox': 873, 'n_words': 158}