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

Port upstream's hashtag handling to glitch-soc #2386

Closed

Conversation

ClearlyClaire
Copy link

Fixes #2381

image

Ported changes

Skipped changes

Additional changes

@ClearlyClaire ClearlyClaire marked this pull request as ready for review August 25, 2023 20:38
import { getStatusContent } from './status_content';

// About two lines on desktop
const VISIBLE_HASHTAGS = 7;

Choose a reason for hiding this comment

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

Could this be an app setting or otherwise configurable?

Choose a reason for hiding this comment

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

This does seem like the type of thing that would be useful to have as a config option, yeah.


const revealedHashtags = expanded
? hashtags
: hashtags.slice(0, VISIBLE_HASHTAGS - 1);
Copy link

Choose a reason for hiding this comment

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

Suggested change
: hashtags.slice(0, VISIBLE_HASHTAGS - 1);
: hashtags.slice(0, VISIBLE_HASHTAGS);

(Taken from: mastodon#26666)

Did a test toot with 10 different hashtags, only 6 were visible and the text said "and 3 more".
The above suggestion fixes that, so 7 hashtags, as configured, are visible. (I don't like the other changes in that PR)

@Leatherface75
Copy link

Leatherface75 commented Aug 26, 2023

I found a problem here

This is how it looks from an instance without this patch

image

and with this patch

image

Maybe it's the swedish letters åäö causing this?
It's showing #farjestad in hashtag bar but that tag doesn't even exist but #färjestad does.
So instead of showing whole line with #färjestad it just shows #farjestad.
Lines without swedish letters seems to move as it should.

@Plastikmensch
Copy link

I found a problem here
[...]
Maybe it's the swedish letters åäö causing this? It's showing #farjestad in hashtag bar but that tag doesn't even exist but #färjestad does. So instead of showing whole line with #färjestad it just shows #farjestad. Lines without swedish letters seems to move as it should.

I can't reproduce that with this PR.
The screenshots also look like vanilla.
My guess is that the instance in the second screenshot is missing 58acaa9 and some of the other fixes included here.

@Leatherface75
Copy link

Leatherface75 commented Aug 26, 2023

I found a problem here
[...]
Maybe it's the swedish letters åäö causing this? It's showing #farjestad in hashtag bar but that tag doesn't even exist but #färjestad does. So instead of showing whole line with #färjestad it just shows #farjestad. Lines without swedish letters seems to move as it should.

I can't reproduce that with this PR. The screenshots also look like vanilla. My guess is that the instance in the second screenshot is missing 58acaa9 and some of the other fixes included here.

I found a problem here
[...]
Maybe it's the swedish letters åäö causing this? It's showing #farjestad in hashtag bar but that tag doesn't even exist but #färjestad does. So instead of showing whole line with #färjestad it just shows #farjestad. Lines without swedish letters seems to move as it should.

I can't reproduce that with this PR. The screenshots also look like vanilla. My guess is that the instance in the second screenshot is missing 58acaa9 and some of the other fixes included here.

I am using this patch and glitch-soc is updated today and it works fine on all tags without swedish letters.
Yes first screenshot was from vanilla but it was only to show how it looks without this patch.
The second one is from todays glitch-soc version with this patch.
Here for an example it works as it should.

image

image

And here another one with swedish letters in tagline then it doesn't work.

image

@Plastikmensch
Copy link

I am using this patch and glitch-soc is updated today and it works fine on all tags without swedish letters. Yes first screenshot was from vanilla but it was only to show how it looks without this patch. Here for an example it works as it should.

For me all of them work as they should.

No bar, since link comes after hashtags:
No hashtag bar because link after hashtags

Correct bar, since hashtags came after link:
visible hashtag bar

Toot text and hashtags containing swedish letters:
visible hashtag bar

I tested every letter provided in your first comment both copied and via unicode, every hashtag combination and even changed the interface language to swedish, with the fix for wrong hashtag count applied and not.
My last guess would've been that it only occurs on remote toots, but since you just provided screenshots of local toots, that's not the case.
The only possibility I see now is either some kind of error while merging or some other change somehow interfering, but since you don't disclose your source, I have no way of checking, and a slight chance there is some other cause for this I can't test for.

@Leatherface75
Copy link

Leatherface75 commented Aug 26, 2023

https://mastodon.helvetet.eu/tags/shl

And that patch you mentioned earlier is there.

    Update dependency rails to v7.0.7.2 (#26612)
        
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 58acaa9ae666d4e40c5b68316513a0fcb9200daf
Author: Renaud Chaput <renchap@gmail.com>
Date:   Wed Aug 23 08:18:07 2023 +0200

    Better hashtag normalization when processing a post (#26614)

commit 452f15be78a3577b137ec516c6a7acfbccd8da47
Author: Claire <claire.github-309c@sitedethib.com>
Date:   Tue Aug 22 19:02:02 2023 +0200

    Move glitch-soc's “Hide followers count” setting to “Show followers count” under “Privacy and reach” tab

commit c053bfc45af942c444432a110e4413d3132043d5
Author: Claire <claire.github-309c@sitedethib.com>
Date:   Wed Aug 16 16:38:33 2023 +0200

@Plastikmensch
Copy link

https://mastodon.helvetet.eu/tags/shl

And that patch you mentioned earlier is there.

    Update dependency rails to v7.0.7.2 (#26612)
        
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 58acaa9ae666d4e40c5b68316513a0fcb9200daf
Author: Renaud Chaput <renchap@gmail.com>
Date:   Wed Aug 23 08:18:07 2023 +0200

    Better hashtag normalization when processing a post (#26614)

commit 452f15be78a3577b137ec516c6a7acfbccd8da47
Author: Claire <claire.github-309c@sitedethib.com>
Date:   Tue Aug 22 19:02:02 2023 +0200

    Move glitch-soc's “Hide followers count” setting to “Show followers count” under “Privacy and reach” tab

commit c053bfc45af942c444432a110e4413d3132043d5
Author: Claire <claire.github-309c@sitedethib.com>
Date:   Wed Aug 16 16:38:33 2023 +0200

Okay now I'm really confused (View from the link you shared):
Screenshot of an earlier toot, but hashtag bar working correctly

This makes me think this is a client-side issue.
Do you have a browser extension installed which could mess with toot content?

@Leatherface75
Copy link

https://mastodon.helvetet.eu/tags/shl
And that patch you mentioned earlier is there.

    Update dependency rails to v7.0.7.2 (#26612)
        
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 58acaa9ae666d4e40c5b68316513a0fcb9200daf
Author: Renaud Chaput <renchap@gmail.com>
Date:   Wed Aug 23 08:18:07 2023 +0200

    Better hashtag normalization when processing a post (#26614)

commit 452f15be78a3577b137ec516c6a7acfbccd8da47
Author: Claire <claire.github-309c@sitedethib.com>
Date:   Tue Aug 22 19:02:02 2023 +0200

    Move glitch-soc's “Hide followers count” setting to “Show followers count” under “Privacy and reach” tab

commit c053bfc45af942c444432a110e4413d3132043d5
Author: Claire <claire.github-309c@sitedethib.com>
Date:   Wed Aug 16 16:38:33 2023 +0200

Okay now I'm really confused (View from the link you shared): Screenshot of an earlier toot, but hashtag bar working correctly

This makes me think this is a client-side issue. Do you have a browser extension installed which could mess with toot content?

Nothing that should matter for Mastodon atleast.
But why does it only happen with swedish letters?

@Leatherface75
Copy link

I tried with another webbrowser and it's same problem there.
Why does it show different for you?

@Plastikmensch
Copy link

Nothing that should matter for Mastodon atleast. But why does it only happen with swedish letters?

Whatever it is, it likely messes with the normalisation done by Mastodon.
It would probably also happen with other special characters.

I tried with another webbrowser and it's same problem there. Why does it show different for you?

Honestly, I have no idea.

@Leatherface75
Copy link

Leatherface75 commented Aug 26, 2023

Nothing that should matter for Mastodon atleast. But why does it only happen with swedish letters?

Whatever it is, it likely messes with the normalisation done by Mastodon. It would probably also happen with other special characters.

I tried with another webbrowser and it's same problem there. Why does it show different for you?

Honestly, I have no idea.

This is really strange.
It's same on my tablet so different webbrowsers, tablets etc makes no difference.
But when it seems to works for you i guess the server is ok atleast.
And yes i have tried remove cache and cookies in webbrowser.

@Leatherface75
Copy link

I have same problem on mastodon.social so i see same problem in vanilla Mastodon and not only my instance.

@Plastikmensch
Copy link

This is really strange. It's same on my tablet so different webbrowsers, tablets etc makes no difference. But when it seems to works for you i guess the server is ok atleast. And yes i have tried remove cache and cookies in webbrowser.

It is indeed strange.
I think this issue depends on system language.
I use en_GB for all my devices and I guess you are using sv.
The collator seems to use the system/browser language, which with how this is configured fails for swedish.

Can you try the following patch and see if that fixes it?

diff --git a/app/javascript/flavours/glitch/components/hashtag_bar.tsx b/app/javascript/flavours/glitch/components/hashtag_bar.tsx
index 674c481b8..f50be8a36 100644
--- a/app/javascript/flavours/glitch/components/hashtag_bar.tsx
+++ b/app/javascript/flavours/glitch/components/hashtag_bar.tsx
@@ -71,7 +71,7 @@ function uniqueHashtagsWithCaseHandling(hashtags: string[]) {
 }

 // Create the collator once, this is much more efficient
-const collator = new Intl.Collator(undefined, {
+const collator = new Intl.Collator('en', {
   sensitivity: 'base', // we use this to emulate the ASCII folding done on the server-side, hopefuly more efficiently
 });

@Leatherface75
Copy link

Leatherface75 commented Aug 27, 2023

This is really strange. It's same on my tablet so different webbrowsers, tablets etc makes no difference. But when it seems to works for you i guess the server is ok atleast. And yes i have tried remove cache and cookies in webbrowser.

It is indeed strange. I think this issue depends on system language. I use en_GB for all my devices and I guess you are using sv. The collator seems to use the system/browser language, which with how this is configured fails for swedish.

Can you try the following patch and see if that fixes it?

diff --git a/app/javascript/flavours/glitch/components/hashtag_bar.tsx b/app/javascript/flavours/glitch/components/hashtag_bar.tsx
index 674c481b8..f50be8a36 100644
--- a/app/javascript/flavours/glitch/components/hashtag_bar.tsx
+++ b/app/javascript/flavours/glitch/components/hashtag_bar.tsx
@@ -71,7 +71,7 @@ function uniqueHashtagsWithCaseHandling(hashtags: string[]) {
 }

 // Create the collator once, this is much more efficient
-const collator = new Intl.Collator(undefined, {
+const collator = new Intl.Collator('en', {
   sensitivity: 'base', // we use this to emulate the ASCII folding done on the server-side, hopefuly more efficiently
 });

Ok that seems to help.
But seems it doesn't always move the tagline if there is a link after.
But that is another problem or if it's by design i don't know.
How does this look for you?

https://mastodon.helvetet.eu/@Anders_S@mastodon.nu/110094029130047998

@Plastikmensch
Copy link

This is really strange. It's same on my tablet so different webbrowsers, tablets etc makes no difference. But when it seems to works for you i guess the server is ok atleast. And yes i have tried remove cache and cookies in webbrowser.

It is indeed strange. I think this issue depends on system language. I use en_GB for all my devices and I guess you are using sv. The collator seems to use the system/browser language, which with how this is configured fails for swedish.
Can you try the following patch and see if that fixes it?

diff --git a/app/javascript/flavours/glitch/components/hashtag_bar.tsx b/app/javascript/flavours/glitch/components/hashtag_bar.tsx
index 674c481b8..f50be8a36 100644
--- a/app/javascript/flavours/glitch/components/hashtag_bar.tsx
+++ b/app/javascript/flavours/glitch/components/hashtag_bar.tsx
@@ -71,7 +71,7 @@ function uniqueHashtagsWithCaseHandling(hashtags: string[]) {
 }

 // Create the collator once, this is much more efficient
-const collator = new Intl.Collator(undefined, {
+const collator = new Intl.Collator('en', {
   sensitivity: 'base', // we use this to emulate the ASCII folding done on the server-side, hopefuly more efficiently
 });

Ok that seems to help. But seems it doesn't always move the tagline if there is a link after. But that is another problem or if it's by design i don't know.

The hashtag bar is only supposed to appear when the last line of a toot only contains hashtags, so a link after hashtags would prevent that.
Does that still happen on some toots?

@Plastikmensch
Copy link

Plastikmensch commented Aug 27, 2023

How does this look for you?

https://mastodon.helvetet.eu/@Anders_S@mastodon.nu/110094029130047998

It has no hashtag bar for me, but looking at it it should have.
So the patch doesn't seem to work universally unfortunately :/

Edit: Oh wait, that link redirected me directly to the original instance, whoops.
Looking at yours, everything looks correct to me, so this patch seems to work.

@Leatherface75
Copy link

This is really strange. It's same on my tablet so different webbrowsers, tablets etc makes no difference. But when it seems to works for you i guess the server is ok atleast. And yes i have tried remove cache and cookies in webbrowser.

It is indeed strange. I think this issue depends on system language. I use en_GB for all my devices and I guess you are using sv. The collator seems to use the system/browser language, which with how this is configured fails for swedish.
Can you try the following patch and see if that fixes it?

diff --git a/app/javascript/flavours/glitch/components/hashtag_bar.tsx b/app/javascript/flavours/glitch/components/hashtag_bar.tsx
index 674c481b8..f50be8a36 100644
--- a/app/javascript/flavours/glitch/components/hashtag_bar.tsx
+++ b/app/javascript/flavours/glitch/components/hashtag_bar.tsx
@@ -71,7 +71,7 @@ function uniqueHashtagsWithCaseHandling(hashtags: string[]) {
 }

 // Create the collator once, this is much more efficient
-const collator = new Intl.Collator(undefined, {
+const collator = new Intl.Collator('en', {
   sensitivity: 'base', // we use this to emulate the ASCII folding done on the server-side, hopefuly more efficiently
 });

Ok that seems to help. But seems it doesn't always move the tagline if there is a link after. But that is another problem or if it's by design i don't know.

The hashtag bar is only supposed to appear when the last line of a toot only contains hashtags, so a link after hashtags would prevent that. Does that still happen on some toots?

I don't see the logic in that.
This is something me and a lot of others people do.

@Leatherface75
Copy link

But your workaround worked with my problem for toots without links.

image

@Leatherface75
Copy link

Leatherface75 commented Aug 27, 2023

Another improvement that should be possible would be parsing hashtags in the end of line with no text after that.

In this example it should be able to parse #pfas and #norsktut atleast.

image

@Leatherface75
Copy link

Hmm in this example hashtags are after the link and still not moving it.
Seems it doesn't matter if link is before or after hashtags.

https://mastodon.helvetet.eu/@kallekn@mastodonsweden.se/110954671967626898

@Plastikmensch
Copy link

Hmm in this example hashtags are after the link and still not moving it. Seems it doesn't matter if link is before or after hashtags.

https://mastodon.helvetet.eu/@kallekn@mastodonsweden.se/110954671967626898

Ah, that's because there is no empty line between the link and hashtags, so

https://example.com

#These #Are #Hashtags

would create the hashtag bar, but

https://example.com
#These #Are #Hahstags

will not.

@Leatherface75
Copy link

Leatherface75 commented Aug 27, 2023

Nevermind i understand now.
I don't understand the logic of that either.
As it's implemented now makes it just messy.
Atleast my problem i had is fixed now.

@Leatherface75
Copy link

Leatherface75 commented Aug 27, 2023

Experimenting a little.
Bringing back boxes and changed fontsize.

image

Here i am using white color on text

image

And another one with boxes and textcolor more like in vanilla.

image

@ClearlyClaire
Copy link
Author

Oops, messed up the branch, I will re-open with its proper branch, sorry.

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.

Port upstream's hashtag handling
5 participants