Exemplo n.º 1
0
 return TaskQueueStatusStore.waitForPerformRemote(task).then(()=>{
   return DatabaseStore.findBy(Category, {clientId: category.clientId})
   .then((updatedCat)=> {
     if (updatedCat && updatedCat.isSavedRemotely()) {
       return Promise.resolve(updatedCat)
     }
     return Promise.reject(new Error('Could not create Snooze category'))
   })
 })
Exemplo n.º 2
0
  setMetadata = (draftClientId, metadata)=> {
    return DatabaseStore.modelify(Message, [draftClientId])
    .then((messages)=> {
      const {accountId} = messages[0];

      return NylasAPI.authPlugin(this.pluginId, this.pluginName, accountId)
      .then(()=> {
        Actions.setMetadata(messages, this.pluginId, metadata);
      })
      .catch((error)=> {
        NylasEnv.reportError(error);
        NylasEnv.showErrorDialog(`Sorry, we were unable to schedule this message. ${error.message}`);
      });
    });
  };
Exemplo n.º 3
0
 setMetadata = (draftClientId, metadata)=> {
   return (
     DatabaseStore.modelify(Message, [draftClientId])
     .then((messages)=> {
       const {accountId} = messages[0]
       return NylasAPI.authPlugin(this.pluginId, PLUGIN_NAME, accountId)
       .then(()=> {
         Actions.setMetadata(messages, this.pluginId, metadata)
       })
       .catch((error)=> {
         console.error(error)
         NylasEnv.showErrorDialog(error.message)
       })
     })
   )
 };
Exemplo n.º 4
0
export function groupProcessedThreadsByAccountId(categoriesByAccountId, threads) {
  return DatabaseStore.modelify(Thread, _.pluck(threads, 'clientId')).then((updatedThreads)=> {
    const threadsByAccountId = {}
    updatedThreads.forEach((thread)=> {
      const accId = thread.accountId
      if (!threadsByAccountId[accId]) {
        threadsByAccountId[accId] = {
          updatedThreads: [thread],
          snoozeCategoryId: categoriesByAccountId[accId].serverId,
          returnCategoryId: CategoryStore.getInboxCategory(accId).serverId,
        }
      } else {
        threadsByAccountId[accId].updatedThreads.push(thread);
      }
    });
    return Promise.resolve(threadsByAccountId);
  })
}
Exemplo n.º 5
0
 setupQuerySubscription() {
   const query = DatabaseStore.findAll(
     Message, [Message.attributes.pluginMetadata.contains(this.pluginId)]
   )
   this.queryDisposable = Rx.Observable.fromQuery(query).subscribe(this.onScheduledMessagesChanged)
 }
Exemplo n.º 6
0
 .then(()=> DatabaseStore.modelify(Thread, _.pluck(threads, 'id')))