-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathCommentPostPanelViewModel.cs
81 lines (77 loc) · 2.3 KB
/
CommentPostPanelViewModel.cs
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using Common;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System;
using System.Windows;
using System.Windows.Input;
namespace PeriscopeSitePlugin
{
class CommentPostPanelViewModel : ViewModelBase
{
private bool _canPostComment;
public bool CanPostComment
{
get { return _canPostComment; }
set
{
if (_canPostComment == value) return;
_canPostComment = value;
RaisePropertyChanged();
}
}
public ICommand PostCommentCommand { get; }
private async void PostComment()
{
if (CanPostComment)
{
CanPostComment = false;
var commentTemp = Comment;
Comment = "";
try
{
await _commentProvider.PostCommentAsync(commentTemp);
}
catch (Exception ex)
{
_logger.LogException(ex, "", $"Comment={commentTemp}");
Comment = commentTemp;
}
CanPostComment = true;
}
}
private string _comment;
private readonly PeriscopeCommentProvider2 _commentProvider;
private readonly ILogger _logger;
public string Comment
{
get { return _comment; }
set
{
if (_comment == value) return;
_comment = value;
RaisePropertyChanged();
}
}
public CommentPostPanelViewModel(PeriscopeCommentProvider2 commentProvider, ILogger logger)
{
_commentProvider = commentProvider;
_logger = logger;
//_commentProvider.LoggedInStateChanged += (s, e) =>
//{
// CanPostComment = _commentProvider.IsLoggedIn;
// if (!CanPostComment)
// {
// Comment = "未ログインのためコメントできません";
// }
// else
// {
// Comment = "";
// }
//};
PostCommentCommand = new RelayCommand(PostComment);
}
public CommentPostPanelViewModel()
{
}
}
}