From 977301dfc3090cd38fa8dc524d89fbbf448be4e4 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 4 May 2020 12:16:34 +0200 Subject: [PATCH] Get the pad data from team drives when mentionned in a comment --- www/common/outer/async-store.js | 6 +++-- www/common/outer/mailbox-handlers.js | 33 +++++++++++++++++----------- www/common/outer/mailbox.js | 1 + 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 2841d8130..574b2584a 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -528,7 +528,7 @@ define([ /////////////////////// Store //////////////////////////////////// ////////////////////////////////////////////////////////////////// - var getAllStores = function () { + var getAllStores = Store.getAllStores = function () { var stores = [store]; var teamModule = store.modules['team']; if (teamModule) { @@ -2307,6 +2307,7 @@ define([ return; } store.mailbox = Mailbox.init({ + Store: Store, store: store, updateMetadata: function () { broadcast([], "UPDATE_METADATA"); @@ -2415,7 +2416,6 @@ define([ loadUniversal(Profile, 'profile', waitFor); loadUniversal(Team, 'team', waitFor); loadUniversal(History, 'history', waitFor); - loadMailbox(waitFor); cleanFriendRequests(); }).nThen(function () { var requestLogin = function () { @@ -2506,6 +2506,8 @@ define([ proxy.on('change', [Constants.tokenKey], function () { broadcast([], "UPDATE_TOKEN", { token: proxy[Constants.tokenKey] }); }); + + loadMailbox(); }); }; diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index 194d375d2..7889aa6e1 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -541,15 +541,18 @@ define([ var channel = content.channel; if (!channel) { return void cb(true); } - var res = ctx.store.manager.findChannel(channel); var title, href; - // Check if the pad is in our drive - res.some(function (obj) { - if (!obj.data) { return; } - href = obj.data.href || obj.data.roHref; - title = obj.data.filename || obj.data.title; - return true; + ctx.Store.getAllStores().some(function (s) { + var res = s.manager.findChannel(channel); + // Check if the pad is in our drive + return res.some(function (obj) { + if (!obj.data) { return; } + if (href && !obj.data.href) { return; } // We already have the VIEW url, we need EDIT + href = obj.data.href || obj.data.roHref; + title = obj.data.filename || obj.data.title; + if (obj.data.href) { return true; } // Abort only if we have the EDIT url + }); }); // If we don't have the edit url, ignore this notification @@ -597,12 +600,16 @@ define([ var res = ctx.store.manager.findChannel(channel); var title, href; - // Check if the pad is in our drive - res.some(function (obj) { - if (!obj.data) { return; } - href = obj.data.href || obj.data.roHref; - title = obj.data.filename || obj.data.title; - return true; + ctx.Store.getAllStores().some(function (s) { + var res = s.manager.findChannel(channel); + // Check if the pad is in our drive + return res.some(function (obj) { + if (!obj.data) { return; } + if (href && !obj.data.href) { return; } // We already have the VIEW url, we need EDIT + href = obj.data.href || obj.data.roHref; + title = obj.data.filename || obj.data.title; + if (obj.data.href) { return true; } // Abort only if we have the EDIT url + }); }); // Add the title diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index ce9bbe850..8e29333be 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -431,6 +431,7 @@ proxy.mailboxes = { var mailbox = {}; var store = cfg.store; var ctx = { + Store: cfg.Store, store: store, pinPads: cfg.pinPads, updateMetadata: cfg.updateMetadata,