Example #1
0
 public CapturePanel(MorphicSession morphicSession, ILogger <CapturePanel> logger, IServiceProvider serviceProvider)
 {
     this.morphicSession = morphicSession;
     this.logger         = logger;
     this.InitializeComponent();
     this.Loaded += this.OnLoaded;
 }
 public TravelWindow(MorphicSession morphicSession, ILogger <TravelWindow> logger, IServiceProvider serviceProvider)
 {
     this.morphicSession  = morphicSession;
     this.logger          = logger;
     this.serviceProvider = serviceProvider;
     this.InitializeComponent();
 }
 public ApplyPanel(MorphicSession morphicSession, ILogger <ApplyPanel> logger, Backups backups)
 {
     this.morphicSession = morphicSession;
     this.logger         = logger;
     this.backups        = backups;
     this.InitializeComponent();
 }
 public CreateAccountPanel(MorphicSession morphicSession, ILogger <CreateAccountPanel> logger, IServiceProvider serviceProvider)
 {
     this.morphicSession  = morphicSession;
     this.logger          = logger;
     this.serviceProvider = serviceProvider;
     this.InitializeComponent();
 }
        public LoginPanel(MorphicSession morphicSession, ILogger <LoginPanel> logger, SessionOptions options, IServiceProvider serviceProvider)
        {
            this.morphicSession  = morphicSession;
            this.logger          = logger;
            this.serviceProvider = serviceProvider;
            UriBuilder?builder = new UriBuilder(options.FontEndUri);

            builder.Path = "/password/reset";
            this.ForgotPasswordUriString = builder.Uri.AbsoluteUri;
            this.InitializeComponent();
        }
 public CopyStartPanel(MorphicSession morphicSession, IServiceProvider serviceProvider)
 {
     this.morphicSession  = morphicSession;
     this.serviceProvider = serviceProvider;
     this.InitializeComponent();
 }
 public TravelCompletedPanel(MorphicSession morphicSession, ILogger <TravelCompletedPanel> logger)
 {
     this.morphicSession = morphicSession;
     this.logger         = logger;
     this.InitializeComponent();
 }
Example #8
0
 public Backups(MorphicSession morphicSession, ILogger <Backups> logger, IServiceProvider serviceProvider)
 {
     this.morphicSession  = morphicSession;
     this.logger          = logger;
     this.serviceProvider = serviceProvider;
 }
        /// <summary>
        /// Loads the bar for the given session. If the user is a member of several, either the last one is used,
        /// or a selection dialog is presented.
        /// </summary>
        /// <param name="session">The current session.</param>
        /// <param name="showCommunityId">Force this community to show.</param>
        public async Task LoadSessionBarAsync(MorphicSession session, string communityId, string?morphicbarId)
        {
            if (this.firstBar && AppOptions.Current.Launch.BarFile is not null)
            {
                this.LoadFromBarJson(AppOptions.Current.Launch.BarFile);
                return;
            }

            this.Logger.LogInformation($"Loading a bar ({session.Communities.Length} communities)");

            UserBar?bar;

            UserCommunity?community = null;
            UserBar?      userBar   = null;

            //if (session.Communities.Length == 0)
            //{
            //    MessageBox.Show("You are not part of a Morphic community yet.", "Morphic");
            //}
            //else if (session.Communities.Length == 1)
            //{
            //    community = session.Communities.First();
            //}
            //else
            //{
            // The user is a member of multiple communities.

            //// See if any membership has changed
            //bool changed = session.Communities.Length != lastCommunities.Length
            //    || !session.Communities.Select(c => c.Id).OrderBy(id => id)
            //        .SequenceEqual(lastCommunities.OrderBy(id => id));

            if (/*!changed &&*/ communityId is not null)
            {
                community = session.Communities.FirstOrDefault(c => c.Id == communityId);
            }

            //if (community is null)
            //{
            //    this.Logger.LogInformation("Showing community picker");

            //    // Load the bars while the picker is shown
            //    Dictionary<string, Task<UserBar>> bars =
            //        session.Communities.ToDictionary(c => c.Id, c => session.GetBar(c.Id));

            //    // Show the picker
            //    CommunityPickerWindow picker = new CommunityPickerWindow(session.Communities);
            //    bool gotCommunity = picker.ShowDialog() == true;
            //    community = gotCommunity ? picker.SelectedCommunity : null;

            //    if (community is not null)
            //    {
            //        userBar = await bars[community.Id];
            //    }
            //}
            //}

            if (community is not null)
            {
                var legacyBars = await session.GetBarsAsync(community.Id);

                foreach (var legacyBar in legacyBars)
                {
                    var useThisBar = false;
                    if (morphicbarId is null)
                    {
                        // if the user selected this community id instead of a specific morphicbar (Morphic v1.0-v1.2), then use the first bar
                        useThisBar = true;
                    }
                    else if (legacyBar.Id == morphicbarId)
                    {
                        // if the user previously selected this specific morphicbar, use it
                        useThisBar = true;
                    }

                    if (useThisBar == true)
                    {
                        // OBSERVATION: not sure why the "??=" (userBar is null) check is done here; this logic seems brittle
                        if (userBar is null)
                        {
                            userBar = legacyBar;
                            break;
                        }
                    }
                }
                // NOTE: if the morphicbar was not found, we do not set it to null (to remain consistent with previous code logic)

                // added to protect against not finding the specific community bar
                if (userBar is not null)
                {
                    this.Logger.LogInformation($"Showing bar for community {community.Id} {community.Name}");
                    string  barJson = this.GetUserBarJson(userBar);
                    BarData?barData = this.LoadFromBarJson(userBar.Id, barJson);
                    if (barData is not null)
                    {
                        barData.CommunityId = community.Id;
                    }

                    AppOptions.Current.LastCommunity    = community?.Id;
                    AppOptions.Current.LastMorphicbarId = userBar.Id;
                }
                else
                {
                    // if the community or the specific community bar could not be found, show the Basic MorphicBar instead
                    this.LoadBasicMorphicBar();

                    AppOptions.Current.LastCommunity    = null;
                    AppOptions.Current.LastMorphicbarId = null;
                }
            }
            else
            {
                // if the community could not be found, show the Basic MorphicBar instead
                this.LoadBasicMorphicBar();

                AppOptions.Current.LastCommunity    = null;
                AppOptions.Current.LastMorphicbarId = null;
            }
        }