mirror of
https://github.com/jellyfin/jellyfin-uwp.git
synced 2024-11-23 05:59:43 +00:00
Merge pull request #41 from Killerherts/Recovery-gitFix
Rebase PR: Revert WebView2 Update, Fix URL Validation (Failed Update Rollback)
This commit is contained in:
commit
0817ae8241
@ -32,35 +32,46 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Background="{StaticResource Color10}">
|
||||
<Image x:Name="logo" Source="/Assets/OnBoardingLogo.png" Stretch="Uniform" HorizontalAlignment="Center" Height="80" />
|
||||
<Image
|
||||
x:Name="logo"
|
||||
Source="/Assets/OnBoardingLogo.png"
|
||||
Stretch="Uniform"
|
||||
HorizontalAlignment="Center"
|
||||
Height="80" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1" Padding="0 40 0 0">
|
||||
<StackPanel x:Name="pnlMain" HorizontalAlignment="Center" VerticalAlignment="Top" Width="640">
|
||||
<TextBlock
|
||||
x:Name="txtTitle"
|
||||
Text="Connect to Server" Foreground="White" FontSize="{StaticResource FontL}" Margin="0 0 0 28" FontFamily="{StaticResource JellyfinFamilyFont}" />
|
||||
<TextBlock FontFamily="{StaticResource JellyfinFamilyFont}"
|
||||
Text="Host:"
|
||||
Foreground="{StaticResource Color100}" FontSize="{StaticResource FontM}" />
|
||||
<TextBox x:Name="txtUrl" Style="{StaticResource PrimaryTextBox}" Margin="0 8 0 8" />
|
||||
<TextBlock FontFamily="{StaticResource JellyfinFamilyFont}"
|
||||
Text="ex: 192.168.1.100:8096 or https://myserver.com. The protocol 'http://' and 'https://' will be automatically added."
|
||||
Foreground="{StaticResource Color90}" FontSize="{StaticResource FontS}"
|
||||
Margin="0 0 0 28 "/>
|
||||
<StackPanel
|
||||
x:Name="pnlMain"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Top"
|
||||
Width="640">
|
||||
<TextBlock
|
||||
x:Name="txtTitle"
|
||||
Text="Connect to Jellyfin Server"
|
||||
Foreground="White" FontSize="{StaticResource FontL}"
|
||||
Margin="0 0 0 28" FontFamily="{StaticResource JellyfinFamilyFont}"
|
||||
HorizontalAlignment="Center" />
|
||||
<TextBox
|
||||
x:Name="txtUrl"
|
||||
Style="{StaticResource PrimaryTextBox}"
|
||||
Margin="0 8 0 8"
|
||||
PlaceholderText="ex: 192.168.1.100:8096 or demo.jellyfin.org"/>
|
||||
<TextBlock
|
||||
x:Name="txtError"
|
||||
FontFamily="{StaticResource JellyfinFamilyFont}"
|
||||
Text="We're unable to connect to the selected server right now. Please ensure it is running and try again"
|
||||
HorizontalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="Collapsed"
|
||||
FontSize="{StaticResource FontM}"
|
||||
Margin="0 -16 0 20"
|
||||
Foreground="#CF4A4A" />
|
||||
|
||||
<Button x:Name="btnConnect" Style="{StaticResource PrimaryButton}" Content="Connect" />
|
||||
x:Name="txtError"
|
||||
FontFamily="{StaticResource JellyfinFamilyFont}"
|
||||
Text="We're unable to connect to the selected server right now. Please ensure it is running and try again"
|
||||
HorizontalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="Collapsed"
|
||||
FontSize="{StaticResource FontM}"
|
||||
Margin="1 1 1 20"
|
||||
Foreground="#CF4A4A" />
|
||||
<Button
|
||||
x:Name="btnConnect"
|
||||
Style="{StaticResource PrimaryButton}"
|
||||
Content="Connect" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
|
@ -82,8 +82,10 @@ namespace Jellyfin.Views
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//add scheme to uri if not included
|
||||
Uri testUri = new UriBuilder(uriString).Uri;
|
||||
|
||||
// check URL exists
|
||||
HttpWebRequest request;
|
||||
HttpWebResponse response;
|
||||
@ -92,9 +94,33 @@ namespace Jellyfin.Views
|
||||
request = (HttpWebRequest)WebRequest.Create(testUri);
|
||||
response = (HttpWebResponse)(await request.GetResponseAsync());
|
||||
}
|
||||
catch (Exception)
|
||||
catch (WebException ex)
|
||||
{
|
||||
return false;
|
||||
// Handle web exceptions here
|
||||
if (ex.Response != null && ex.Response is HttpWebResponse errorResponse)
|
||||
{
|
||||
int statusCode = (int)errorResponse.StatusCode;
|
||||
if (statusCode >= 300 && statusCode <= 308)
|
||||
{
|
||||
// Handle Redirect
|
||||
string newLocation = errorResponse.Headers["Location"];
|
||||
if (!string.IsNullOrEmpty(newLocation))
|
||||
{
|
||||
uriString = newLocation;
|
||||
return await CheckURLValidAsync(uriString); // Recursively check the new location
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateErrorMessage(statusCode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle other exceptions
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (response == null || response.StatusCode != HttpStatusCode.OK)
|
||||
@ -112,7 +138,17 @@ namespace Jellyfin.Views
|
||||
}
|
||||
}
|
||||
|
||||
// If everything is OK, update the URI before saving it
|
||||
Central.Settings.JellyfinServer = uriString;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void UpdateErrorMessage(int statusCode)
|
||||
{
|
||||
txtError.Visibility = Visibility.Visible;
|
||||
txtError.Text = $"Error: {statusCode}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user