use std::path::Path;
use serde_json::Value;
use super::Login;
use super::local::{self, State};
use crate::record::landing::destination::unblock;
use crate::record::landing::rules::Block;
use crate::record::landing::slots::directory;
pub fn changed(home: &Path, prior: Option<&State>, report: &Value) {
if report["updated"] != true {
return;
}
let tag = local::state(home)
.ok()
.flatten()
.and_then(|state| state.etag);
if tag.is_some() && tag.as_deref() != prior.and_then(|state| state.etag.as_deref()) {
let _ = unblock(&directory(home), |_| true, false);
}
}
pub fn signed_in(home: &Path, args: &Login) {
if !args.refresh {
let _ = unblock(
&directory(home),
|block| block.reason == Block::Credential.name(),
false,
);
}
}