aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-09-13 22:05:47 -0400
committerbobzel <zzzman@gmail.com>2022-09-13 22:05:47 -0400
commit8e2abf1a858b0f85e1821c28a8c6dbf6285edfdd (patch)
tree14138648501b183b73f6d45165bb4335702abba6
parentcea66bd846e886776bcb9d376f0aa7c88cf73504 (diff)
clicking to open a shared dashboard opens an alias of it.
-rw-r--r--src/client/views/DashboardView.tsx9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/client/views/DashboardView.tsx b/src/client/views/DashboardView.tsx
index 6415601f1..35aa67ac8 100644
--- a/src/client/views/DashboardView.tsx
+++ b/src/client/views/DashboardView.tsx
@@ -53,7 +53,14 @@ export class DashboardView extends React.Component {
clickDashboard = async (e: React.MouseEvent, dashboard: Doc) => {
if (e.detail === 2) {
Doc.AddDocToList(Doc.MySharedDocs, 'viewed', dashboard);
- Doc.ActiveDashboard = dashboard;
+ if (DocListCast(Doc.MySharedDocs.data).includes(dashboard)) {
+ // choose an appropriate alias or make one. --- choose the first alias that (1) user owns, (2) has no context field ... otherwise make a new alias
+ const bestAlias = DocListCast(dashboard.aliases).find(doc => doc.author === Doc.CurrentUserEmail);
+ const nextBestAlias = DocListCast(dashboard.aliases).find(doc => doc.author === Doc.CurrentUserEmail);
+ Doc.ActiveDashboard = bestAlias ?? nextBestAlias ?? Doc.MakeAlias(dashboard);
+ } else {
+ Doc.ActiveDashboard = dashboard;
+ }
Doc.ActivePage = 'dashboard';
}
};