Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/persistant columns #75

Merged
merged 5 commits into from
Apr 11, 2024
Merged

Conversation

BrianWhitneyAI
Copy link
Contributor

@BrianWhitneyAI BrianWhitneyAI commented Apr 4, 2024

The purpose of this PR is to resolve #57 and introduce persistent columns (Display Annotations) for users after closing the app.

Testing procedure:

  1. Initial feature test

    • Select and deselect display annotations
    • Reload and check columns match
  2. Spam testing

    • Quickly click and unclick lots of random things
  3. Testing with annotation hierarchy

    • Different combinations

@BrianWhitneyAI BrianWhitneyAI requested a review from SeanLeRoy April 4, 2024 17:56
@@ -8,6 +8,7 @@ import { PersistedConfig, PersistedConfigKeys } from "../services/PersistentConf
import interaction, { InteractionStateBranch } from "./interaction";
import metadata, { MetadataStateBranch } from "./metadata";
import selection, { SelectionStateBranch } from "./selection";
import Annotation from "../entity/Annotation";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import belongs with the above grouping (so as a new line above line 6)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this import causes the app to go blank. I am completely lost on why.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled locally and tried this as well, also caused a load error for me when put anywhere from line 8 up:
Uncaught ReferenceError: Cannot access 'Annotation' before initialization

console.error("Failed to fetch annotations", err);
}

dispatch(receiveAnnotations(annotations));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to dispatch this if we don't have annotations & the defaults wouldn't be able to render anyway without them. In that case it seems like it would be best to have the catch statement look like:

            console.error("Failed to fetch annotations", err);
            done();
            return;

and the dispatch(receiveAnnotations(annotations)); should move into the try block as the last line in it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved in f3b21ab

@@ -157,15 +157,19 @@ export const DESELECT_DISPLAY_ANNOTATION = makeConstant(
);

export interface DeselectDisplayAnnotationAction {
payload: Annotation | Annotation[];
payload: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? why

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this made it a little easer to read mirroring the SelectDisplayAnnotationAction so that both have action.payload.annotation as the annotation rather than action.payload for one and action.payload.annotation for another

@@ -123,9 +123,9 @@ export default makeReducer<SelectionStateBranch>(
sortColumn: action.payload,
}),
[DESELECT_DISPLAY_ANNOTATION]: (state, action) => {
const displayAnnotations = without(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this what without was doing? Why the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was the source of the reselect bug I was talking about, for some reason the annotations returned by the persist are slightly different and this dont get removed with the without function. The same is true for comparing the objects directly. This is what i was saying about not liking my solution as much.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like lodash's without function doesn't support this kind of object comparison -- unless the objects share a reference, they aren't considered equal. I'm curious if this use of without worked when the payload to deselectDisplayAnnotation was previously just annotation instead of {annotation}?
But also am fine with the use of filter here

[PersistedConfigKeys.UserSelectedApplications]: userSelectedApplications,
};
if (JSON.stringify(appState) !== JSON.stringify(persistentConfigService.getAll())) {
persistentConfigService.persist({
[PersistedConfigKeys.CsvColumns]: csvColumns,
[PersistedConfigKeys.UserSelectedApplications]: userSelectedApplications,
...appState,
[PersistedConfigKeys.HasUsedApplicationBefore]: hasUsedApplicationBefore,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this should also be in the appState object - this isn't because of your changeset just seems buggy because otherwise isn't this always true?
JSON.stringify(appState) !== JSON.stringify(persistentConfigService.getAll())
If you agree I'd put [PersistedConfigKeys.HasUsedApplicationBefore]: true into the appState object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved in f3b21ab

return;
}

if (!displayAnnotations.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I initially loaded this branch locally, got an error on load that caused the app to fail because displayAnnotations was set to [undefined] which technically has length 1. Brian and I were able to special case around it temporarily, but since then haven't been able to replicate the error. Wanted to check if anyone else (@SeanLeRoy ?) has seen this bug locally?

@BrianWhitneyAI BrianWhitneyAI merged commit e9a2fcf into master Apr 11, 2024
3 checks passed
@BrianWhitneyAI BrianWhitneyAI deleted the feature/persistant-columns branch April 11, 2024 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-use columns selected last time
3 participants