Skip to content

SF-2028 Hide community checking text when requested#1967

Merged
marksvc merged 7 commits intomasterfrom
task/745682c8
Oct 4, 2023
Merged

SF-2028 Hide community checking text when requested#1967
marksvc merged 7 commits intomasterfrom
task/745682c8

Conversation

@marksvc
Copy link
Copy Markdown
Collaborator

@marksvc marksvc commented Jul 13, 2023

Note that this PR introduces a regression: "Audio unavailable" is not shown when the user navigates to a chapter that does not have audio. This can be addressed in followup.


Note that this PR is composed in different commits. There are two refactor commits at the beginning of the PR that are separate from other changes. Hopefully that will make the review easier. It is okay if the whole PR is squashed together for submitting. Although I would like for all the commit messages to be retained. The individual commits were not individually tested.


This change is Reviewable

@marksvc marksvc marked this pull request as draft July 13, 2023 15:28
@marksvc marksvc added the will require testing PR should not be merged until testers confirm testing is complete label Jul 13, 2023
@marksvc
Copy link
Copy Markdown
Collaborator Author

marksvc commented Jul 13, 2023

This is a simple change to add a checkbox to the Settings page to toggle whether Scripture text should be shown or not. It also introduces a field to the data model. It does not actually influence whether Scripture is shown or not in the Community Checking area.

I wanted to make the checkbox only appear in Settings for projects that have Scripture audio. To do that, I ended up with a BehaviorSubject, and doing some RxJS in ngOnInit. Is this the right approach, or over-complicating things?

In an earlier version of the code I had a Settings component projectHasAudio() method. I since removed that, but left in the part of its test that checks if the checkbox is present or absent. This isn't working, but I need to look at whether I am constructing the right situation for ngOnInit to detect Scripture audio.

One thing that I don't have working are the Storybook tests. There are Stories for the permutations of whether the Scripture audio feature flag is on or off, and whether the project has Scripture audio. But it isn't working at present.

@marksvc
Copy link
Copy Markdown
Collaborator Author

marksvc commented Jul 13, 2023

Video showing the checkbox on Settings page of a project with Scripture audio:

hide-scr-checkbox.webm

@marksvc
Copy link
Copy Markdown
Collaborator Author

marksvc commented Aug 21, 2023

I continued having trouble with Storybook and removed it from the PR.

It occurred to me that if the project administrator adds Scripture Audio, checks the box to hide Scripture text, and then removes their Scripture Audio, the "hide Scripture text" selection will still be set. I started to write some code to make the checkbox be shown again so it could be deselected, but stopped when I realized that a broader and better solution is to show Scripture text in instances where we do not have Scripture audio for a given chapter.

@marksvc marksvc marked this pull request as ready for review August 21, 2023 21:16
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 21, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Files Coverage Δ
...imeServer/scriptureforge/models/checking-config.ts 100.00% <ø> (ø)
...rver/scriptureforge/models/sf-project-test-data.ts 100.00% <ø> (ø)
...dio-player/single-button-audio-player.component.ts 82.60% <100.00%> (+0.79%) ⬆️
...e/ClientApp/src/app/settings/settings.component.ts 86.85% <100.00%> (+0.38%) ⬆️
...o/audio-player-base/audio-player-base.component.ts 100.00% <100.00%> (ø)
...ure/ClientApp/src/app/shared/audio/audio-player.ts 87.50% <100.00%> (-1.24%) ⬇️
...tApp/src/xforge-common/models/json-realtime-doc.ts 100.00% <ø> (ø)
...ClientApp/src/xforge-common/models/realtime-doc.ts 76.66% <ø> (ø)
src/SIL.XForge.Scripture/Models/CheckingConfig.cs 100.00% <100.00%> (ø)
...c/SIL.XForge.Scripture/Models/SFProjectSettings.cs 90.00% <100.00%> (+1.11%) ⬆️
... and 4 more

... and 2 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

@josephmyers josephmyers self-assigned this Aug 22, 2023
@josephmyers
Copy link
Copy Markdown
Collaborator

josephmyers commented Aug 22, 2023

This may not be an issue when it's not behind the feature flag, but I'm seeing the green checkmark when enabling Scripture Audio. Further, it doesn't go away on page refresh. Note that when seeing the issue, I had never clicked the setting before. I'll keep testing

Recording.2023-08-22.084731.mp4

@josephmyers
Copy link
Copy Markdown
Collaborator

Based on the team meeting, I'm gonna pause my review on this while we finish up the rest of the work on this

@marksvc
Copy link
Copy Markdown
Collaborator Author

marksvc commented Aug 22, 2023 via email

@marksvc marksvc marked this pull request as draft August 23, 2023 22:44
@marksvc marksvc force-pushed the task/745682c8 branch 4 times, most recently from 54db8f7 to fdbe4b0 Compare August 29, 2023 20:51
@marksvc
Copy link
Copy Markdown
Collaborator Author

marksvc commented Aug 29, 2023

Videos showing behaviour on phone and wider:

phone-audio-sizing-3.webm
desktop-audio-sizing-3.webm

@marksvc marksvc force-pushed the task/745682c8 branch 2 times, most recently from fc02ba3 to 45067aa Compare August 29, 2023 21:32
@marksvc
Copy link
Copy Markdown
Collaborator Author

marksvc commented Aug 29, 2023

This PR is using $any('*') as a workaround until this PR is merged: angular-split/angular-split#289
After that, just '*' can be used.

@marksvc marksvc marked this pull request as ready for review August 29, 2023 21:55
@josephmyers
Copy link
Copy Markdown
Collaborator

@marksvc, I'm still seeing the issue with the green checkmark! I'll keep reviewing though

Copy link
Copy Markdown
Collaborator

@josephmyers josephmyers left a comment

Choose a reason for hiding this comment

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

I really like this feature! It looks cool to take away the text and see only the chapter audio with the questions and answers. And our GUI adapts to the absence pretty well. It will be really interesting to see this once all the open PR's for scripture audio get merged, particularly the more usability-focused ones. In fact, I think we should wait til some of them are before merging this, so that we can make sure the workflow really clicks. For example, how does it work when we swap the Delete button for Close? How does this work when finishing the chapter hides the audio player?

I also like that you can minimize the player while listening to get more screen space. Good thinking!

I found a minor issue where if you enable the setting and delete all audio files, it breaks things. Plus, you can't uncheck the setting until you had audio back.
image.png

I'm also wondering if we need a place to indicate to admin's when audio projects have chapters that don't have audio yet. What happens if checkers log into these projects and there's no way to listen to or read the verses? Aren't they screwed? What do you think? Maybe that's a separate feature.

Reviewed 17 of 18 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @marksvc)


src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking.component.html line 138 at r2 (raw file):

                unit="pixel"
              >
                <as-split-area [size]="hideChapterText ? 109 : $any('*')" [maxSize]="hideChapterText ? 109 : null">

Is there any way we can not use magic numbers here? It makes this part brittle. For example, when the audio is unavailable/missing, it takes up too much space, since the player is shorter.


src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking.component.scss line 125 at r2 (raw file):

    #answer-panel {
      height: 100%;
      padding-top: 12px;

I think this guy looks funky now. We probably still need it, just elsewhere?

image.png


src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking.component.ts line 1178 at r2 (raw file):

  }

  private showOrHideScriptureText(): void {

This is misnamed (or missing functionality). It only shows the player, never hides it.


src/SIL.XForge.Scripture/ClientApp/src/app/settings/settings.component.html line 130 at r2 (raw file):

                </div>
              </div>
              <div class="tool-setting" *ngIf="featureFlags.scriptureAudio.enabled && hasTextAudioDocs">

I'm a little skeptical about the extra hasTextAudioDocs check here. Let's say they want to check this setting and then add their audio files. They will come here and not find anything. Thoughts?


src/SIL.XForge.Scripture/ClientApp/src/assets/i18n/non_checking_en.json line 268 at r2 (raw file):

    "translations_will_be_suggested": "Translations for words and phrases will be suggested as you edit Scripture based on the project or resource selected above.",
    "users_can_share_the_project": "Allow users to invite people outside Paratext to the project. They will receive the same role as the user who invited them.",
    "hide_community_checking_text": "Do not show Scripture text in Community Checking area. Checkers will need to listen to the Scripture audio.",

In my opinion, this is a little wordy. We could save some space by saying "Hide Scripture text" and moving the second sentence to a tooltip with app-info. I don't think we need to specify Community Checking again, since we're in the Community Checking section. What do you think?

Copy link
Copy Markdown
Collaborator Author

@marksvc marksvc left a comment

Choose a reason for hiding this comment

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

I don't know why there is trouble with your green checkbox. Here is a video showing how it's working on my machine. I wonder if it would be helpful for you to enable the Scripture audio feature before going to the Settings page; maybe that might influence the behaviour? We can play with it together on a video call and see if we can figure it out.

[See chat for video scr-audio-checkbox.webm]

In fact, I think we should wait til some of them are before merging this, so that we can make sure the workflow really clicks. For example, how does it work when we swap the Delete button for Close? How does this work when finishing the chapter hides the audio player?

Okay. I think my preference would be to get it merged in without waiting. Then as we make changes like to the Delete button or hiding the audio player, it can be in light of this positioning and also the reality that text will be hidden sometimes.

Plus, you can't uncheck the setting until you had audio back.

Right! That's something we'll have to decide how to handle. My thinking is, if a project does not have any audio files, but has hide-text enabled, then we should still show the hide-text checkbox so they can uncheck it. (Okay, as discussed later, I made the checkbox visible regardless.)

I found a minor issue where if you enable the setting and delete all audio files, it breaks things.

Yeah. We'll need to decide what to do in situations where a project admin wants hide-text, but also doesn't have audio for a chapter. Probably there should be a graphic or something to indicate that audio is missing for that chapter.

I'll start on this now. It could go into a followup PR if we finish the review before I'm done.

I'm also wondering if we need a place to indicate to admin's when audio projects have chapters that don't have audio yet. What happens if checkers log into these projects and there's no way to listen to or read the verses?

So here's some useful framing. My thinking before was that maybe we could show text for chapters that don't have audio (like even if hide-text was enabled). But Nathaniel's picture of the hide-text situation is that some language projects don't want to show the text at all. So I'm seeing the hide-text setting as an all-or-nothing setting. You either hide all the text, or you don't hide all the text.

So, yes, I do think it would be useful to project admins to be able to see that the have audio uploaded for Mark 1-8 and 10-16, but are missing audio for Mark 9. But because of the above framing, if there is no audio for Mark 9, then in a hide-text situation there will be no Scripture for the checkers to work with until it's uploaded. (Rather than us trying to compensate by showing the text.)

As we play with the audio feature we may find that it's easy to upload all your chapters, or obvious to an admin if a chapter is missing. We can see.

Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @josephmyers)


src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking.component.html line 138 at r2 (raw file):

Previously, josephmyers wrote…

Is there any way we can not use magic numbers here? It makes this part brittle. For example, when the audio is unavailable/missing, it takes up too much space, since the player is shorter.

Right. I would prefer to make it some how be set to the size of the height of the audio player, or perhaps the height of the visible contents. I wasn't successful at finding a way to do that, and so manually determined the required px needed. Do you have any suggestions?

Regarding when the audio is missing, I don't think we need to worry about that for this situation. We can design a no-audio-available thing to show. It can still be 109 px tall, and if there is no audio available, and hide-text is enabled, then it's not a chapter for checkers to work in.


src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking.component.scss line 125 at r2 (raw file):
Regarding the white padding above "1 Answers": If I turn off hide-text and show the Scripture, I do see that the Scripture text does not have a corresponding bottom padding. It might be that the question area padding at the top should be eliminated. That might be something to throw out to the team to get UI opinions on, and make a jira issue for.

looks funky now

I don't think this is something new with this PR, is it? I see the behaviour when hide-text is off.


src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking.component.ts line 1178 at r2 (raw file):

Previously, josephmyers wrote…

This is misnamed (or missing functionality). It only shows the player, never hides it.

Ahh. But consider! In ngOnInit(), we do an initial showOrHideScriptureText(). Then we listen to this.projectDoc.remoteChanges$, upon which we again call showOrHideScriptureText().

That way the display in the community checking area will be dynamically updated in response to project settings changes regarding hide-text. For example, if you open one window and go to a chapter with audio. And you open another window and go to Settings. Then you select hide-text in the Settings window, the Checking window will instantly update by hiding the text and showing the audio player. If in Settings you clear hide-text, then in the Checking window, the text is again revealed (but it doesn't close the open audio player).

See the below video for a demonstration.

So I would say the method does cause the text to be hidden or shown. And there is a bonus effect of showing the audio player if hide-text is enabled.

But maybe there's something I can improve so it's more evident?

[see slack for hide-dynamic.webm]


src/SIL.XForge.Scripture/ClientApp/src/app/settings/settings.component.html line 130 at r2 (raw file):

Previously, josephmyers wrote…

I'm a little skeptical about the extra hasTextAudioDocs check here. Let's say they want to check this setting and then add their audio files. They will come here and not find anything. Thoughts?

Hmm. If a user has a text project and no Audio files, my thinking was that I don't want them to go turn off showing their Scripture text. And talking about hiding Scripture text and showing audio might not even make sense if they are all about thinking of showing the text and people engaging with the text.

That said, (1) making the hide-text checkbox sometimes show and sometimes not show might be less desirable for support and help documentation. And (2) if they admin goes and turns off Scripture text, and the text disappears, that's what they told it to do and they can come turn it back on again.

So maybe we should just have the checkbox be visible all the time. I'll go ahead and do that.


src/SIL.XForge.Scripture/ClientApp/src/assets/i18n/non_checking_en.json line 268 at r2 (raw file):

Previously, josephmyers wrote…

In my opinion, this is a little wordy. We could save some space by saying "Hide Scripture text" and moving the second sentence to a tooltip with app-info. I don't think we need to specify Community Checking again, since we're in the Community Checking section. What do you think?

Good point. We could fit in both thoughts if we use "Hide Scripture text. Checkers will listen to audio." What do you think about that?

Copy link
Copy Markdown
Collaborator Author

@marksvc marksvc left a comment

Choose a reason for hiding this comment

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

Okay, check it out, if there is no audio for a chapter, then part of the player is shown, but also "Audio unavailable". The cod eto do this was already there, but there was a particular situation that we were hitting where we only saw the back,play,forward,trash buttons, and not the "Audio unavailable" message. I adjusted the code so that it more consistently shows this message when there is no audio. The player is not 109 px high. I'm not sure that's a big deal. And if a user gets this player showing on their screen in a situation where they do want to be looking at Scripture text, it may be good for it not to be taller. Do you think it's significant for the "Audio unavailable" player to be matching the full height of the text+audio split area?

See video of behaviour:
audio-unavail-after-delete.webm

Reviewable status: 13 of 19 files reviewed, 9 unresolved discussions (waiting on @josephmyers)

@marksvc
Copy link
Copy Markdown
Collaborator Author

marksvc commented Aug 30, 2023

Fixed some code scanning alerts.

Copy link
Copy Markdown
Collaborator

@josephmyers josephmyers left a comment

Choose a reason for hiding this comment

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

There's assuredly more work to be done on this, but what you have looks good. Thanks for sticking with it!

Reviewed 6 of 6 files at r17, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @github-code-scanning[bot])

Copy link
Copy Markdown
Collaborator Author

@marksvc marksvc left a comment

Choose a reason for hiding this comment

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

Thanks for looking at the design with me!

Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @github-code-scanning[bot])

@marksvc marksvc added ready to test and removed will require testing PR should not be merged until testers confirm testing is complete labels Sep 26, 2023
@marksvc marksvc added testing complete Testing of PR is complete and should no longer hold up merging of the PR and removed ready to test labels Oct 2, 2023
@marksvc marksvc enabled auto-merge (squash) October 2, 2023 18:40
@marksvc marksvc disabled auto-merge October 2, 2023 22:58
@marksvc
Copy link
Copy Markdown
Collaborator Author

marksvc commented Oct 2, 2023

@josephmyers A change to checking-scripture-audio-player.component.spec happened in the mean time, and I needed to make an adjustment to the PR.

The first commit, audio: subscribe when targets are ready adjusts checking-scripture-audio-player so that some audio subscriptions happen after audioPlayer.isAudioAvailable$.

checking-scripture-audio-player has an initial timing from

beforeEach(
...
  env.component.audioPlayer.timing = ...

With the audio: subscribe when ... commit, when test "emits section heading when timing starts at greater than 0 seconds" runs, it again sets env.component.audioPlayer.timing, but not before the verse change subscription has already run its contents on the original timing data.

To handle this, I have modified the checking-scripture-audio-player.component.spec.ts so that we can feed in the desired timing values when we create the test environment. It starts off with the timing values we are going to use. In the test now it starts off with the correct timing values, and emits the expected reference right away (not necessarily when 'play' is clicked).

Unfortunately, this led to a further problem, with test "emits verse changed event". I modified that test in light of there already being an emit that happened.

I wanted to run this change thru the review process since it wasn't just a simple adjustment.

@RaymondLuong3 I see that you wrote the "emits section heading when timing starts at greater than 0 seconds" test. Should I further adjust what I have done? The test now is a little odd since it doesn't really need the play button to be clicked at this time.
Right now the test reads,

    const env = new TestEnvironment({
      timings: [
        { textRef: 's', from: 1.0, to: 2.0 },
        { textRef: '1', from: 2.0, to: 3.0 }
      ]
    });
    const verseChangedSpy = jasmine.createSpy('verseChanged');
    env.component.audioPlayer.currentVerseChanged.subscribe(verseChangedSpy);
    env.wait();

    env.playButton.nativeElement.click();
    env.audioPlayer.audio.timeUpdated$.next();
    env.wait();

    expect(verseChangedSpy).toHaveBeenCalledWith('s_1');

But it runs just as well as

    const env = new TestEnvironment({
      timings: [
        { textRef: 's', from: 1.0, to: 2.0 },
        { textRef: '1', from: 2.0, to: 3.0 }
      ]
    });
    const verseChangedSpy = jasmine.createSpy('verseChanged');
    env.component.audioPlayer.currentVerseChanged.subscribe(verseChangedSpy);
    env.wait();

    expect(verseChangedSpy).toHaveBeenCalledWith('s_1');

    env.playButton.nativeElement.click();
    env.audioPlayer.audio.timeUpdated$.next();
    env.wait();

or even

    const env = new TestEnvironment({
      timings: [
        { textRef: 's', from: 1.0, to: 2.0 },
        { textRef: '1', from: 2.0, to: 3.0 }
      ]
    });
    const verseChangedSpy = jasmine.createSpy('verseChanged');
    env.component.audioPlayer.currentVerseChanged.subscribe(verseChangedSpy);
    env.wait();

    expect(verseChangedSpy).toHaveBeenCalledWith('s_1');

Maybe I should adjust it to this last example? Do you have any input?
(Actually, I'll go ahead and set it to the last one for now.)

@josephmyers
Copy link
Copy Markdown
Collaborator

Thanks for your detailed explanation. This change, and the change to the tests, makes sense. We don't want to have to click play before the verseChanged event starts working. Without it we have to keep the "play on open" feature, as verseChanged will break if we ever remove that. Now, we've uncoupled those behaviors.

The only thing I'm really concerned about in this class is the removal of the beforeEach(). Instead of re-introducing manual setup to each test so that you can set up spies in a subset, why not add the spies to the beforeEach()? It keeps duplication out, and any future tests that want to spy can do so. And it helps keep the behavior we're talking about, that the verseChanged is fired on init, clearly defined in the test, notably "emits verse changed event"

@marksvc
Copy link
Copy Markdown
Collaborator Author

marksvc commented Oct 3, 2023

@josephmyers I started working on putting things back into a beforeEach(), but quickly found that if I do that, I won't necessarily know what timings to start the component with. So I kept the env = new TestEnvironment in the individual tests.

But I put spy subscriptions into the TestEnvironment, to seek to fulfill some of what you're looking for here.

What do you think of this?

@josephmyers
Copy link
Copy Markdown
Collaborator

Alright, sounds good 👍

`this.audioPlayer!.audio!` may be null in ngAfterViewInit. Wait until
it is ready, and then subscribe.
Allow tests to define and pass in a customized test project to the
TestEnvironment ctor.
And show audio player by default.
In situations where we hide the text, intending just for the audio
player to be used, make the text+audio area have a
size of the height needed by the audio player, to just show
the audio player. The audio area can still be made smaller to move it
up out of the way.

In the case where we do not hide the text, and whether or not there is
audio, still we show the question area as a smaller area near the
bottom of the screen, with the Scripture text area using most of the
available space.

Rename to clarify meaning of AudioStatus.Initializing.

AudioPlayerBaseComponent is first instantiated with a null `source`,
and later given the real one (or not). Make it start out with a timing
slider to make it start out with a likely height so the
CheckingComponent doesn't need to wait for APBC to build itself, to
know its height.

Remove close button from audio player when hide-text, which would
leave user with no audio player and no Scripture text.
Prevents flicker when switching between questions in different
chapters, where the audio player timing slider starts out at 100% and
right away goes down to 0. Now it starts at 0.
@marksvc marksvc enabled auto-merge (squash) October 4, 2023 17:09
@marksvc marksvc merged commit 7b8cb7f into master Oct 4, 2023
@marksvc marksvc deleted the task/745682c8 branch October 4, 2023 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing complete Testing of PR is complete and should no longer hold up merging of the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants