in tools/MonoDevelop.Figma/NodeBuilders/BundlerNodeBuilder.cs [62:122]
public override void BuildNode (ITreeBuilder builder, object dataObject, NodeInfo nodeInfo)
{
if (dataObject is Projects.ProjectFile file)
{
if (file.IsFigmaDesignerFile ())
{
nodeInfo.OverlayBottomLeft = HasError(file, file.DependsOnFile) ? figmaOverlayError : figmaOverlay;
}
else if (file.IsFigmaCSFile (out var designerFile))
{
nodeInfo.OverlayBottomLeft = HasError(designerFile, file) ? figmaOverlayError : figmaOverlay;
}
}
else if (dataObject is ProjectFolder pr) {
if (pr.IsDocumentDirectoryBundle ())
{
FigmaBundle bundle = null;
try {
bundle = FigmaBundle.FromDirectoryPath(pr.Path.FullPath);
} catch (Exception ex) {
//if the bundle is removed by any reason whyle updating
LoggingService.LogError("CustomFigmaFundlerNodeBuilder", ex);
}
if (bundle != null && bundle.Manifest != null && !string.IsNullOrEmpty (bundle.Manifest.DocumentTitle)) {
nodeInfo.Label = bundle.Manifest.DocumentTitle;
} else {
nodeInfo.Label = pr.Path.FileNameWithoutExtension;
}
nodeInfo.ClosedIcon = nodeInfo.Icon = Context.GetIcon (Stock.Package);
Task.Run(() => {
var query = new FigmaFileVersionQuery(bundle.FileId);
var figmaFileVersions = FigmaSharp.AppContext.Api.GetFileVersions(query).versions;
return figmaFileVersions
.GroupByCreatedAt()
.OrderByDescending (s => s.created_at)
.FirstOrDefault ();
}).ContinueWith (s => {
if (s.Result != null && s.Result.id != bundle.Version.id) {
Runtime.RunInMainThread(() => {
nodeInfo.StatusIcon = Context.GetIcon(packageUpdateIcon);
if (s.Result.IsNamed)
nodeInfo.StatusMessage = $"Update available: {s.Result.label}";
else
nodeInfo.StatusMessage = $"Update available: {s.Result.created_at.ToString("g")}";
});
}
});
return;
}
if (pr.IsFigmaDirectory ()) {
nodeInfo.Label = FigmaFolderLabel;
nodeInfo.ClosedIcon = nodeInfo.Icon = Context.GetIcon (Resources.Icons.FigmaPad);
return;
}
}
}