Skip to content

Commit

Permalink
Fix Thanked property in TopicInfo.cs and remove
Browse files Browse the repository at this point in the history
Thanks property in TopicPage.razor.ViewModel.cs
  • Loading branch information
rwecho committed Jan 5, 2024
1 parent 73ffde3 commit b6c1034
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/V2ex.Api/TopicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public bool IsThanked
}
}

[XPath("//div[@id='Wrapper']//div[@id='topic_thank']/a/text()")]
[XPath("//div[@id='Wrapper']//div[@id='topic_thank']/span")]
[SkipNodeNotFound]
public string? Thanked { get; set; }

Expand Down
5 changes: 1 addition & 4 deletions src/V2ex.Blazor.Shared/Pages/TopicPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@
if (viewModel.Thanked)
{
<button class="text-sm text-gray-400 p-2 flex flex-row space-x-2 items-center font-medium bg-gray-50 rounded-lg">
<span>@viewModel.Thanks</span>
<svg xmlns="http://www.w3.org/2000/svg" class="fill-red-400" height="16" width="16" viewBox="0 0 512 512">
<!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.-->
<path d="M323.8 34.8c-38.2-10.9-78.1 11.2-89 49.4l-5.7 20c-3.7 13-10.4 25-19.5 35l-51.3 56.4c-8.9 9.8-8.2 25 1.6 33.9s25 8.2 33.9-1.6l51.3-56.4c14.1-15.5 24.4-34 30.1-54.1l5.7-20c3.6-12.7 16.9-20.1 29.7-16.5s20.1 16.9 16.5 29.7l-5.7 20c-5.7 19.9-14.7 38.7-26.6 55.5c-5.2 7.3-5.8 16.9-1.7 24.9s12.3 13 21.3 13L448 224c8.8 0 16 7.2 16 16c0 6.8-4.3 12.7-10.4 15c-7.4 2.8-13 9-14.9 16.7s.1 15.8 5.3 21.7c2.5 2.8 4 6.5 4 10.6c0 7.8-5.6 14.3-13 15.7c-8.2 1.6-15.1 7.3-18 15.2s-1.6 16.7 3.6 23.3c2.1 2.7 3.4 6.1 3.4 9.9c0 6.7-4.2 12.6-10.2 14.9c-11.5 4.5-17.7 16.9-14.4 28.8c.4 1.3 .6 2.8 .6 4.3c0 8.8-7.2 16-16 16H286.5c-12.6 0-25-3.7-35.5-10.7l-61.7-41.1c-11-7.4-25.9-4.4-33.3 6.7s-4.4 25.9 6.7 33.3l61.7 41.1c18.4 12.3 40 18.8 62.1 18.8H384c34.7 0 62.9-27.6 64-62c14.6-11.7 24-29.7 24-50c0-4.5-.5-8.8-1.3-13c15.4-11.7 25.3-30.2 25.3-51c0-6.5-1-12.8-2.8-18.7C504.8 273.7 512 257.7 512 240c0-35.3-28.6-64-64-64l-92.3 0c4.7-10.4 8.7-21.2 11.8-32.2l5.7-20c10.9-38.2-11.2-78.1-49.4-89zM32 192c-17.7 0-32 14.3-32 32V448c0 17.7 14.3 32 32 32H96c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32H32z" />
Expand All @@ -295,8 +294,7 @@
else
{
<button class="text-sm text-gray-400 p-2 flex flex-row space-x-2 items-center font-medium bg-gray-50 rounded-lg"
@onclick="ThankTopic">
<span>@viewModel.Thanks</span>
@onclick="ThankTopic">
<svg xmlns="http://www.w3.org/2000/svg" class="fill-gray-400" height="16" width="16" viewBox="0 0 512 512">
<!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.-->
<path d="M323.8 34.8c-38.2-10.9-78.1 11.2-89 49.4l-5.7 20c-3.7 13-10.4 25-19.5 35l-51.3 56.4c-8.9 9.8-8.2 25 1.6 33.9s25 8.2 33.9-1.6l51.3-56.4c14.1-15.5 24.4-34 30.1-54.1l5.7-20c3.6-12.7 16.9-20.1 29.7-16.5s20.1 16.9 16.5 29.7l-5.7 20c-5.7 19.9-14.7 38.7-26.6 55.5c-5.2 7.3-5.8 16.9-1.7 24.9s12.3 13 21.3 13L448 224c8.8 0 16 7.2 16 16c0 6.8-4.3 12.7-10.4 15c-7.4 2.8-13 9-14.9 16.7s.1 15.8 5.3 21.7c2.5 2.8 4 6.5 4 10.6c0 7.8-5.6 14.3-13 15.7c-8.2 1.6-15.1 7.3-18 15.2s-1.6 16.7 3.6 23.3c2.1 2.7 3.4 6.1 3.4 9.9c0 6.7-4.2 12.6-10.2 14.9c-11.5 4.5-17.7 16.9-14.4 28.8c.4 1.3 .6 2.8 .6 4.3c0 8.8-7.2 16-16 16H286.5c-12.6 0-25-3.7-35.5-10.7l-61.7-41.1c-11-7.4-25.9-4.4-33.3 6.7s-4.4 25.9 6.7 33.3l61.7 41.1c18.4 12.3 40 18.8 62.1 18.8H384c34.7 0 62.9-27.6 64-62c14.6-11.7 24-29.7 24-50c0-4.5-.5-8.8-1.3-13c15.4-11.7 25.3-30.2 25.3-51c0-6.5-1-12.8-2.8-18.7C504.8 273.7 512 257.7 512 240c0-35.3-28.6-64-64-64l-92.3 0c4.7-10.4 8.7-21.2 11.8-32.2l5.7-20c10.9-38.2-11.2-78.1-49.4-89zM32 192c-17.7 0-32 14.3-32 32V448c0 17.7 14.3 32 32 32H96c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32H32z" />
Expand Down Expand Up @@ -845,7 +843,6 @@
throw new InvalidOperationException(result.Message);
}
viewModel.Thanked = true;
viewModel.Thanks += 1;
if (result.Once > 0)
{
viewModel.Once = result.Once.ToString();
Expand Down
16 changes: 0 additions & 16 deletions src/V2ex.Blazor.Shared/Pages/TopicPage.razor.ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,12 @@ List<string> Tags
return;
}

var match1 = Regex.Match(value, @"(\d+) 次点击");
if (match1.Success)
{
this.Clicks = int.Parse(match1.Groups[1].Value);
}

var match2 = Regex.Match(value, @"(\d+) 人收藏");
if (match2.Success)
{
this.Likes = int.Parse(match2.Groups[1].Value);
}
var match3 = Regex.Match(value, @"(\d+) 人感谢");
if (match3.Success)
{
this.Thanks = int.Parse(match3.Groups[1].Value);
}
}
}

Expand Down Expand Up @@ -83,7 +73,6 @@ List<string> Tags
}
}

public int Clicks { get; set; }

public int RepliesCount { get; set; }

Expand All @@ -94,11 +83,6 @@ public int Likes
get; set;
}

public int Thanks
{
get; set;
}


public bool Thanked { get; set; }
public bool Ignored { get; set; }
Expand Down

0 comments on commit b6c1034

Please sign in to comment.