diff --git a/Connectors/Tekla/Speckle.Connector.TeklaShared/HostApp/TeklaDocumentModelStore.cs b/Connectors/Tekla/Speckle.Connector.TeklaShared/HostApp/TeklaDocumentModelStore.cs index a05759f30..bae477566 100644 --- a/Connectors/Tekla/Speckle.Connector.TeklaShared/HostApp/TeklaDocumentModelStore.cs +++ b/Connectors/Tekla/Speckle.Connector.TeklaShared/HostApp/TeklaDocumentModelStore.cs @@ -12,6 +12,7 @@ public class TeklaDocumentModelStore : DocumentModelStore private readonly ILogger _logger; private readonly ISqLiteJsonCacheManager _jsonCacheManager; private readonly TSM.Events _events; + private readonly TSM.Model _model; private string? _modelKey; public TeklaDocumentModelStore( @@ -24,10 +25,11 @@ ISqLiteJsonCacheManagerFactory jsonCacheManagerFactory _logger = logger; _jsonCacheManager = jsonCacheManagerFactory.CreateForUser("ConnectorsFileData"); _events = new TSM.Events(); + _model = new TSM.Model(); + GenerateKey(); _events.ModelLoad += () => { - var model = new TSM.Model(); - _modelKey = Crypt.Md5(model.GetInfo().ModelPath, length: 32); + GenerateKey(); LoadState(); OnDocumentChanged(); }; @@ -39,6 +41,8 @@ ISqLiteJsonCacheManagerFactory jsonCacheManagerFactory } } + private void GenerateKey() => _modelKey = Crypt.Md5(_model.GetInfo().ModelPath, length: 32); + protected override void HostAppSaveState(string modelCardState) { try