From 60ebe1b45560fcabb8011c42e15009c197d4dd20 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 13 Sep 2022 15:35:49 -0400
Subject: cleanup

---
 src/client/views/PropertiesView.tsx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 2708c561d..555320aed 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -7,7 +7,7 @@ import { intersection } from 'lodash';
 import { action, autorun, computed, Lambda, observable } from 'mobx';
 import { observer } from 'mobx-react';
 import { ColorState, SketchPicker } from 'react-color';
-import { AclAdmin, AclAugment, AclEdit, AclPrivate, AclReadonly, AclSelfEdit, AclSym, AclUnset, DataSym, Doc, Field, HeightSym, NumListCast, Opt, StrListCast, WidthSym } from '../../fields/Doc';
+import { AclAdmin, AclAugment, AclEdit, AclPrivate, AclReadonly, AclSelfEdit, AclSym, AclUnset, DataSym, Doc, DocListCast, Field, HeightSym, NumListCast, Opt, StrListCast, WidthSym } from '../../fields/Doc';
 import { Id } from '../../fields/FieldSymbols';
 import { InkField } from '../../fields/InkField';
 import { List } from '../../fields/List';
@@ -33,6 +33,7 @@ import { PropertiesDocBacklinksSelector } from './PropertiesDocBacklinksSelector
 import { PropertiesDocContextSelector } from './PropertiesDocContextSelector';
 import './PropertiesView.scss';
 import { DefaultStyleProvider } from './StyleProvider';
+import { listSpec } from '../../fields/Schema';
 const higflyout = require('@hig/flyout');
 export const { anchorPoints } = higflyout;
 export const Flyout = higflyout.default;
-- 
cgit v1.2.3-70-g09d2


From 7869b13de37b9d910f455be79f6bf55ecfe49b26 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 13 Sep 2022 15:51:20 -0400
Subject: make filterBox reuse filter if it is unsaved.

---
 src/client/views/PropertiesView.tsx  | 14 +++++++++++---
 src/client/views/nodes/FilterBox.tsx |  2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 555320aed..842664402 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -1157,13 +1157,21 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
      */
     createNewFilterDoc = () => {
         if (this.selectedDoc) {
+            const curFilterDoc = DocCast(this.selectedDoc.currentFilter);
             const currentDocFilters = this.selectedDoc._docFilters;
             const currentDocRangeFilters = this.selectedDoc._docRangeFilters;
             this.selectedDoc._docFilters = new List<string>();
             this.selectedDoc._docRangeFilters = new List<string>();
-            (this.selectedDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
-            (this.selectedDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
-            this.selectedDoc.currentFilter = FilterBox.createFilterDoc();
+            if (DocListCast(Doc.UserDoc().savedFilters).includes(curFilterDoc)) {
+                curFilterDoc._docFiltersList = currentDocFilters;
+                curFilterDoc._docRangeFiltersList = currentDocRangeFilters;
+                this.selectedDoc.currentFilter = FilterBox.createFilterDoc();
+            } else {
+                Doc.GetProto(curFilterDoc).data = undefined;
+                Doc.GetProto(curFilterDoc).title = 'Unnamed Filter';
+                curFilterDoc._docFiltersList = undefined;
+                curFilterDoc._docRangeFiltersList = undefined;
+            }
         }
     };
 
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 54501cfa2..04d252abe 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -379,7 +379,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps>() {
      * Changes the title of the filterDoc
      */
     onTitleValueChange = (val: string) => {
-        this.props.Document.title = val || `FilterDoc for ${FilterBox.targetDoc?.title}`;
+        Doc.GetProto(this.props.Document).title = val || `FilterDoc for ${FilterBox.targetDoc?.title}`;
         return true;
     };
 
-- 
cgit v1.2.3-70-g09d2

