2019-04-24 18:23:03 +03:00
|
|
|
|
using Bit.Core.Abstractions;
|
|
|
|
|
using Bit.Core.Utilities;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Bit.App.Pages
|
|
|
|
|
{
|
2019-05-01 17:11:49 +03:00
|
|
|
|
public partial class ViewPage : BaseContentPage
|
2019-04-24 18:23:03 +03:00
|
|
|
|
{
|
|
|
|
|
private readonly IBroadcasterService _broadcasterService;
|
|
|
|
|
private ViewPageViewModel _vm;
|
|
|
|
|
|
|
|
|
|
public ViewPage(string cipherId)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
|
|
|
|
|
_vm = BindingContext as ViewPageViewModel;
|
|
|
|
|
_vm.Page = this;
|
|
|
|
|
_vm.CipherId = cipherId;
|
2019-05-01 17:11:49 +03:00
|
|
|
|
SetActivityIndicator();
|
2019-04-24 18:23:03 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-01 17:11:49 +03:00
|
|
|
|
protected override async void OnAppearing()
|
2019-04-24 18:23:03 +03:00
|
|
|
|
{
|
|
|
|
|
base.OnAppearing();
|
|
|
|
|
_broadcasterService.Subscribe(nameof(ViewPage), async (message) =>
|
|
|
|
|
{
|
|
|
|
|
if(message.Command == "syncCompleted")
|
|
|
|
|
{
|
|
|
|
|
var data = message.Data as Dictionary<string, object>;
|
|
|
|
|
if(data.ContainsKey("successfully"))
|
|
|
|
|
{
|
|
|
|
|
var success = data["successfully"] as bool?;
|
|
|
|
|
if(success.HasValue && success.Value)
|
|
|
|
|
{
|
|
|
|
|
await _vm.LoadAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2019-05-01 17:11:49 +03:00
|
|
|
|
await LoadOnAppearedAsync(_scrollView, true, () => _vm.LoadAsync());
|
2019-04-24 18:23:03 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnDisappearing()
|
|
|
|
|
{
|
|
|
|
|
base.OnDisappearing();
|
|
|
|
|
_broadcasterService.Unsubscribe(nameof(ViewPage));
|
2019-04-26 07:26:09 +03:00
|
|
|
|
_vm.CleanUp();
|
2019-04-24 18:23:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|