-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
946 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/NuSocial/Converters/ContentStringToMarkdownHtmlConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Markdig; | ||
using Markdig.Renderers.Roundtrip; | ||
using Markdig.Syntax; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NuSocial.Converters; | ||
|
||
public class ContentStringToMarkdownHtmlConverter : IValueConverter | ||
{ | ||
private static MarkdownPipeline Pipeline = new MarkdownPipelineBuilder().UseEmphasisExtras().UseGridTables().UsePipeTables().UseTaskLists().UseAutoLinks().Build(); | ||
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
try | ||
{ | ||
return Markdown.Parse((string)value, true).ToHtml(Pipeline); | ||
} | ||
catch (Exception) | ||
{ | ||
return (string)value; | ||
} | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using CommunityToolkit.Mvvm.Messaging; | ||
using Nostr.Client.Keys; | ||
using NuSocial.Messages; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NuSocial | ||
{ | ||
public class GlobalSetting | ||
{ | ||
private User? _user; | ||
|
||
public static GlobalSetting Instance { get; } = new GlobalSetting(); | ||
|
||
public User CurrentUser | ||
{ | ||
get => _user; | ||
set | ||
{ | ||
if (value?.PublicKey != null) | ||
{ | ||
_user = value; | ||
UpdateUser(_user.PublicKey, _user.PrivateKey); | ||
} | ||
} | ||
} | ||
|
||
private static void UpdateUser(NostrPublicKey publicKey, NostrPrivateKey? privateKey) | ||
{ | ||
if (privateKey != null) | ||
{ | ||
WeakReferenceMessenger.Default.Send<NostrUserChangedMessage>(new((publicKey.Hex, privateKey.Hex))); | ||
} | ||
else | ||
{ | ||
WeakReferenceMessenger.Default.Send<NostrUserChangedMessage>(new((publicKey.Hex, string.Empty))); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
using CommunityToolkit.Mvvm.Messaging.Messages; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NuSocial.Messages | ||
{ | ||
public class LogoutMessage : ValueChangedMessage<bool?> | ||
{ | ||
public LogoutMessage(bool? value = null) : base(value) | ||
{ | ||
} | ||
} | ||
|
||
public class ResetNavMessage : ValueChangedMessage<string?> | ||
{ | ||
public ResetNavMessage(string? route = null) : base(route) | ||
{ | ||
} | ||
} | ||
} | ||
|
||
using CommunityToolkit.Mvvm.Messaging.Messages; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NuSocial.Messages | ||
{ | ||
public class LogoutMessage : ValueChangedMessage<bool?> | ||
{ | ||
public LogoutMessage(bool? value = null) : base(value) | ||
{ | ||
} | ||
} | ||
|
||
public class ResetNavMessage : ValueChangedMessage<string?> | ||
{ | ||
public ResetNavMessage(string? route = null) : base(route) | ||
{ | ||
} | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using CommunityToolkit.Mvvm.Messaging.Messages; | ||
using Nostr.Client.Keys; | ||
|
||
namespace NuSocial.Messages | ||
{ | ||
public class NostrUserChangedMessage : ValueChangedMessage<(string pubKey, string privKey)> | ||
{ | ||
public NostrUserChangedMessage((string pubKey, string privKey) value) : base(value) | ||
{ | ||
} | ||
} | ||
|
||
public class NostrPostMessage : ValueChangedMessage<string?> | ||
{ | ||
public NostrPostMessage(string? value = null) : base(value) | ||
{ | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.