From 8e2abf1a858b0f85e1821c28a8c6dbf6285edfdd Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 13 Sep 2022 22:05:47 -0400 Subject: clicking to open a shared dashboard opens an alias of it. --- src/client/views/DashboardView.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') 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'; } }; -- cgit v1.2.3-70-g09d2