summaryrefslogtreecommitdiff
path: root/Juick/Classes/MyUriMapper.cs
blob: 8add68313032ab5f393e9f8bac1916a1844e84f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Navigation;

namespace Juick.Classes
{
    public class MyUriMapper : UriMapperBase
    {
        public override Uri MapUri(Uri uri)
        {
            string tempUri = uri.OriginalString;
            string mappedUri;

            // Launch from the photo share picker.
            // Incoming URI example: /MainPage.xaml?Action=ShareContent&FileId=%7BA3D54E2D-7977-4E2B-B92D-3EB126E5D168%7D
            if ((tempUri.Contains("ShareContent")) && (tempUri.Contains("FileId")))
            {
                mappedUri = tempUri.Replace("LaunchPage", "NewPostView");
                return new Uri(mappedUri, UriKind.Relative);
            }

            if (uri.OriginalString == "/LaunchPage.xaml")
            {
                var realPage = App.AppContext.Account.IsAuthenticated ? "MainPage" : "LoginView";
                mappedUri = tempUri.Replace("LaunchPage", realPage);
                return new Uri(mappedUri, UriKind.Relative);
            }

            // Otherwise perform normal launch.
            return uri;
        }
    }
}