Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacSchemm committed Jan 7, 2021
1 parent 78618e2 commit a3d96c3
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 39 deletions.
8 changes: 7 additions & 1 deletion CrosspostSharp3/ArtworkForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Forms;

namespace CrosspostSharp3 {
Expand Down Expand Up @@ -75,7 +76,12 @@ public async void LoadImage(IPostBase artwork) {
btnView.Enabled = _origWrapper.ViewURL != null;

// Download image (if applicable)
_downloaded = await Downloader.DownloadAsync(_origWrapper);
try {
_downloaded = await Downloader.DownloadAsync(_origWrapper);
} catch (WebException ex) {
MessageBox.Show(this, ex.Message);
_downloaded = null;
}

// Get photo (or thumbnail of video)
if (_downloaded != null) {
Expand Down
2 changes: 1 addition & 1 deletion CrosspostSharp3/FurryNetwork/FurryNetworkPostForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private async void PopulateIcon() {
var character = await _client.GetCharacterAsync(_characterName);
string avatar = character.Avatars.Tiny ?? character.Avatars.GetLargest();
if (avatar != null) {
var req = WebRequestFactory.Create(avatar);
var req = WebRequest.Create(avatar);
using (var resp = await req.GetResponseAsync())
using (var stream = resp.GetResponseStream())
using (var ms = new MemoryStream()) {
Expand Down
3 changes: 2 additions & 1 deletion CrosspostSharp3/Inkbunny/InkbunnyPostForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Forms;

namespace CrosspostSharp3.Inkbunny {
Expand All @@ -29,7 +30,7 @@ private async void Form_Shown(object sender, EventArgs e) {
try {
lblUsername1.Text = await _client.WhoamiAsync();

var req = WebRequestFactory.Create(await _client.GetUserIconAsync());
var req = WebRequest.Create(await _client.GetUserIconAsync());
using (var resp = await req.GetResponseAsync())
using (var stream = resp.GetResponseStream())
using (var ms = new MemoryStream()) {
Expand Down
17 changes: 6 additions & 11 deletions CrosspostSharp3/TextPost.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
using ArtworkSourceSpecification;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CrosspostSharp3 {
public class TextPost : IPostBase {
public string Title { get; set; }
public string HTMLDescription { get; set; }
public bool Mature { get; set; }
public bool Adult { get; set; }
public IEnumerable<string> Tags { get; set; }
public record TextPost : IPostBase {
public string Title { get; init; }
public string HTMLDescription { get; init; }
public bool Mature { get; init; }
public bool Adult { get; init; }
public IEnumerable<string> Tags { get; init; }

DateTime IPostBase.Timestamp => DateTime.UtcNow;
string IPostBase.ViewURL => null;

public TextPost() { }
}
}
2 changes: 1 addition & 1 deletion CrosspostSharp3/Twitter/TwitterPostForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private async void TwitterPostForm_Shown(object sender, EventArgs e) {
lblUsername1.Text = user.Name;
lblUsername2.Text = "@" + user.ScreenName;

var req = WebRequestFactory.Create(user.ProfileImageUrl);
var req = WebRequest.Create(user.ProfileImageUrl);
using (var resp = await req.GetResponseAsync())
using (var stream = resp.GetResponseStream())
using (var ms = new MemoryStream()) {
Expand Down
3 changes: 2 additions & 1 deletion CrosspostSharp3/Weasyl/WeasylPostForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Forms;

namespace CrosspostSharp3.Weasyl {
Expand Down Expand Up @@ -46,7 +47,7 @@ private async void WeasylPostForm_Shown(object sender, EventArgs e) {

var avatarUrl = await _apiClient.GetAvatarUrlAsync(user.login);

var req = WebRequestFactory.Create(avatarUrl);
var req = WebRequest.Create(avatarUrl);
using (var resp = await req.GetResponseAsync())
using (var stream = resp.GetResponseStream())
using (var ms = new MemoryStream()) {
Expand Down
23 changes: 0 additions & 23 deletions CrosspostSharp3/WebRequestFactory.cs

This file was deleted.

0 comments on commit a3d96c3

Please sign in to comment.