From 84ee5c5ffd1260aafe70465497ad5b4b460fb787 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Wed, 15 Nov 2023 20:01:16 -0800 Subject: [PATCH] follow-topic: Show "follow" icon in recipient headers Together with the preceding few commits which add this icon in some other places in the UI, this completes #5770. Fixes: #5770 --- ...oundEventEditSequence-test.js.snap.android | 120 ++++++++++++------ ...eInboundEventEditSequence-test.js.snap.ios | 120 ++++++++++++------ .../generateInboundEventEditSequence-test.js | 55 ++++++++ .../generateInboundEventEditSequence.js | 15 ++- src/webview/html/__tests__/header-test.js | 2 + src/webview/html/header.js | 8 +- src/webview/static/base.css | 12 ++ 7 files changed, 244 insertions(+), 88 deletions(-) diff --git a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android index 50b5af73d9c..f2dda872427 100644 --- a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android +++ b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android @@ -68,6 +68,8 @@ exports[`getEditSequence correct for interesting changes within a given message exports[`getEditSequence correct for interesting changes within a given message add/remove/change emoji status status emoji: zulip extra -> zulip extra (no change) 1`] = `0`; +exports[`getEditSequence correct for interesting changes within a given message follow a topic 1`] = `1`; + exports[`getEditSequence correct for interesting changes within a given message mute a sender 1`] = `1`; exports[`getEditSequence correct for interesting changes within a given message polls choice added 1`] = `3`; @@ -78,6 +80,8 @@ exports[`getEditSequence correct for interesting changes within a given message exports[`getEditSequence correct for interesting changes within a given message star a message 1`] = `1`; +exports[`getEditSequence correct for interesting changes within a given message unfollow a topic 1`] = `1`; + exports[`getEditSequence correct for interesting changes within a given message unmute a sender 1`] = `1`; exports[`getEditSequence correct for interesting changes within a given message unstar a message 1`] = `1`; @@ -92,7 +96,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1 -
topic 1
+
topic 1
Feb 5, 1995
@@ -136,7 +140,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -185,7 +189,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Feb 19, 1995
@@ -209,7 +213,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 2
+
topic 2
Feb 19, 1995
@@ -241,7 +245,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -265,7 +269,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjI=\\"> # stream 2
-
topic 2
+
topic 2
Mar 5, 1995
@@ -297,7 +301,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -612,7 +616,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Feb 5, 1995
@@ -692,7 +696,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Feb 19, 1995
@@ -716,7 +720,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 2
+
topic 2
Feb 19, 1995
@@ -880,7 +884,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -904,7 +908,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjI=\\"> # stream 2
-
topic 2
+
topic 2
Mar 5, 1995
@@ -928,7 +932,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -1000,7 +1004,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -1526,6 +1530,38 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible all-pm
" `; +exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message in followed topic 1`] = ` +"
+
+ Dec 31, 1969 +
+
+
+ # stream 1 +
+
example topic
+
Dec 31, 1969
+
+
+ \\"Nonrandom +
+
+
+
+ Nonrandom name sender User +
+
11:59 PM
+
+

This is an example stream message.

+ + + +
+ +
" +`; + exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message in unsubscribed stream 1`] = ` "
@@ -1536,7 +1572,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1568,7 +1604,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1610,7 +1646,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1642,7 +1678,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1674,7 +1710,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1706,7 +1742,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1738,7 +1774,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1770,7 +1806,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1802,7 +1838,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1834,7 +1870,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1866,7 +1902,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1898,7 +1934,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1930,7 +1966,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1962,7 +1998,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1994,7 +2030,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2026,7 +2062,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2060,7 +2096,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2092,7 +2128,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2124,7 +2160,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2156,7 +2192,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2655,7 +2691,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Feb 5, 1995
-
topic 1
+
topic 1
Feb 5, 1995
@@ -2695,7 +2731,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Mar 5, 1995
-
topic 1
+
topic 1
Mar 5, 1995
@@ -2740,7 +2776,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Feb 19, 1995
-
topic 1
+
topic 1
Feb 19, 1995
@@ -2760,7 +2796,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream
-
topic 2
+
topic 2
Feb 19, 1995
@@ -2788,7 +2824,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Mar 5, 1995
-
topic 1
+
topic 1
Mar 5, 1995
@@ -2837,7 +2873,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Feb 5, 1995
-
topic 1
+
topic 1
Feb 5, 1995
@@ -2890,7 +2926,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream
-
topic 2
+
topic 2
Feb 19, 1995
@@ -2914,7 +2950,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Mar 5, 1995
-
topic 1
+
topic 1
Mar 5, 1995
diff --git a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios index 50b5af73d9c..f2dda872427 100644 --- a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios +++ b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios @@ -68,6 +68,8 @@ exports[`getEditSequence correct for interesting changes within a given message exports[`getEditSequence correct for interesting changes within a given message add/remove/change emoji status status emoji: zulip extra -> zulip extra (no change) 1`] = `0`; +exports[`getEditSequence correct for interesting changes within a given message follow a topic 1`] = `1`; + exports[`getEditSequence correct for interesting changes within a given message mute a sender 1`] = `1`; exports[`getEditSequence correct for interesting changes within a given message polls choice added 1`] = `3`; @@ -78,6 +80,8 @@ exports[`getEditSequence correct for interesting changes within a given message exports[`getEditSequence correct for interesting changes within a given message star a message 1`] = `1`; +exports[`getEditSequence correct for interesting changes within a given message unfollow a topic 1`] = `1`; + exports[`getEditSequence correct for interesting changes within a given message unmute a sender 1`] = `1`; exports[`getEditSequence correct for interesting changes within a given message unstar a message 1`] = `1`; @@ -92,7 +96,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Feb 5, 1995
@@ -136,7 +140,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -185,7 +189,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Feb 19, 1995
@@ -209,7 +213,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 2
+
topic 2
Feb 19, 1995
@@ -241,7 +245,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -265,7 +269,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjI=\\"> # stream 2
-
topic 2
+
topic 2
Mar 5, 1995
@@ -297,7 +301,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -612,7 +616,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Feb 5, 1995
@@ -692,7 +696,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Feb 19, 1995
@@ -716,7 +720,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 2
+
topic 2
Feb 19, 1995
@@ -880,7 +884,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -904,7 +908,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjI=\\"> # stream 2
-
topic 2
+
topic 2
Mar 5, 1995
@@ -928,7 +932,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -1000,7 +1004,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N background: #123456\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
topic 1
+
topic 1
Mar 5, 1995
@@ -1526,6 +1530,38 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible all-pm
" `; +exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message in followed topic 1`] = ` +"
+
+ Dec 31, 1969 +
+
+
+ # stream 1 +
+
example topic
+
Dec 31, 1969
+
+
+ \\"Nonrandom +
+
+
+
+ Nonrandom name sender User +
+
11:59 PM
+
+

This is an example stream message.

+ + + +
+ +
" +`; + exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message in unsubscribed stream 1`] = ` "
@@ -1536,7 +1572,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1568,7 +1604,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1610,7 +1646,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1642,7 +1678,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1674,7 +1710,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1706,7 +1742,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1738,7 +1774,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1770,7 +1806,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1802,7 +1838,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1834,7 +1870,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1866,7 +1902,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1898,7 +1934,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1930,7 +1966,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1962,7 +1998,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -1994,7 +2030,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2026,7 +2062,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2060,7 +2096,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2092,7 +2128,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2124,7 +2160,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2156,7 +2192,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\"> # stream 1
-
example topic
+
example topic
Dec 31, 1969
@@ -2655,7 +2691,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Feb 5, 1995
-
topic 1
+
topic 1
Feb 5, 1995
@@ -2695,7 +2731,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Mar 5, 1995
-
topic 1
+
topic 1
Mar 5, 1995
@@ -2740,7 +2776,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Feb 19, 1995
-
topic 1
+
topic 1
Feb 19, 1995
@@ -2760,7 +2796,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream
-
topic 2
+
topic 2
Feb 19, 1995
@@ -2788,7 +2824,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Mar 5, 1995
-
topic 1
+
topic 1
Mar 5, 1995
@@ -2837,7 +2873,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Feb 5, 1995
-
topic 1
+
topic 1
Feb 5, 1995
@@ -2890,7 +2926,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream
-
topic 2
+
topic 2
Feb 19, 1995
@@ -2914,7 +2950,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible stream Mar 5, 1995
-
topic 1
+
topic 1
Mar 5, 1995
diff --git a/src/webview/__tests__/generateInboundEventEditSequence-test.js b/src/webview/__tests__/generateInboundEventEditSequence-test.js index 6882f4e53fb..96cc7bb9693 100644 --- a/src/webview/__tests__/generateInboundEventEditSequence-test.js +++ b/src/webview/__tests__/generateInboundEventEditSequence-test.js @@ -29,6 +29,8 @@ import getMessageListElements from '../../message/getMessageListElements'; import { getGlobalSettings } from '../../selectors'; import { getBackgroundData } from '../backgroundData'; import { randString } from '../../utils/misc'; +import { makeMuteState } from '../../mute/__tests__/mute-testlib'; +import { UserTopicVisibilityPolicy } from '../../api/modelTypes'; // Tell ESLint to recognize `check` as a helper function that runs // assertions. @@ -443,6 +445,23 @@ describe('messages -> piece descriptors -> content HTML is stable/sensible', () }); }); + test('message in followed topic', () => { + check({ + narrow: HOME_NARROW, + messages: [baseSingleMessage], + state: eg.reduxStatePlus({ + streams: [...eg.plusReduxState.streams, stream1], + subscriptions: [ + ...eg.plusReduxState.subscriptions, + eg.makeSubscription({ stream: stream1 }), + ], + mute: makeMuteState([ + [stream1, baseSingleMessage.subject, UserTopicVisibilityPolicy.Followed], + ]), + }), + }); + }); + describe('message with reactions', () => { describe('displayEmojiReactionUsers: false', () => { const state = eg.reduxStatePlus({ @@ -991,6 +1010,42 @@ describe('getEditSequence correct for interesting changes', () => { ); }); + test('follow a topic', () => { + const message = eg.streamMessage(); + check( + { + messages: [message], + state: eg.reduxStatePlus({ + mute: makeMuteState([]), + }), + }, + { + messages: [message], + state: eg.reduxStatePlus({ + mute: makeMuteState([[eg.stream, message.subject, UserTopicVisibilityPolicy.Followed]]), + }), + }, + ); + }); + + test('unfollow a topic', () => { + const message = eg.streamMessage(); + check( + { + messages: [message], + state: eg.reduxStatePlus({ + mute: makeMuteState([[eg.stream, message.subject, UserTopicVisibilityPolicy.Followed]]), + }), + }, + { + messages: [message], + state: eg.reduxStatePlus({ + mute: makeMuteState([]), + }), + }, + ); + }); + // TODO(#5208): We haven't settled how we want to track name/avatar test.todo("sender's name/avatar changed"); diff --git a/src/webview/generateInboundEventEditSequence.js b/src/webview/generateInboundEventEditSequence.js index c48576571d6..d0f96be4940 100644 --- a/src/webview/generateInboundEventEditSequence.js +++ b/src/webview/generateInboundEventEditSequence.js @@ -8,6 +8,7 @@ import { ensureUnreachable } from '../generics'; import type { BackgroundData } from './backgroundData'; import messageListElementHtml from './html/messageListElementHtml'; import { getUserStatusFromModel } from '../user-statuses/userStatusesCore'; +import { isTopicFollowed } from '../mute/muteModel'; const NODE_ENV = process.env.NODE_ENV; @@ -72,7 +73,19 @@ function doElementsDifferInterestingly( return !isEqual(oldElement, newElement); case 'header': // TODO(?): False positives on `.subsequentMessage.content` changes - return !isEqual(oldElement, newElement); + if (!isEqual(oldElement, newElement)) { + return true; + } + if (newElement.subsequentMessage?.type === 'stream') { + const message = newElement.subsequentMessage; + if ( + isTopicFollowed(message.stream_id, message.subject, oldBackgroundData.mute) + !== isTopicFollowed(message.stream_id, message.subject, newBackgroundData.mute) + ) { + return true; + } + } + return false; case 'message': { invariant(newElement.type === 'message', 'oldElement.type equals newElement.type'); diff --git a/src/webview/html/__tests__/header-test.js b/src/webview/html/__tests__/header-test.js index fc212f20cf3..99b4eea6afb 100644 --- a/src/webview/html/__tests__/header-test.js +++ b/src/webview/html/__tests__/header-test.js @@ -3,8 +3,10 @@ import * as eg from '../../../__tests__/lib/exampleData'; import header from '../header'; import type { BackgroundData } from '../../backgroundData'; +import { makeMuteState } from '../../../mute/__tests__/mute-testlib'; const backgroundData: BackgroundData = ({ + mute: makeMuteState([]), ownEmail: eg.selfUser.email, subscriptions: [eg.stream], streams: new Map([[eg.stream.stream_id, eg.stream]]), diff --git a/src/webview/html/header.js b/src/webview/html/header.js index 6733053ccc4..66bb506050c 100644 --- a/src/webview/html/header.js +++ b/src/webview/html/header.js @@ -19,6 +19,7 @@ import { streamNameOfStreamMessage, } from '../../utils/recipient'; import { base64Utf8Encode } from '../../utils/encoding'; +import { isTopicFollowed } from '../../mute/muteModel'; const renderTopic = message => // TODO: pin down if '' happens, and what its proper semantics are. @@ -32,7 +33,7 @@ const renderTopic = message => * This is a private helper of messageListElementHtml. */ export default ( - { ownUser, subscriptions }: BackgroundData, + { mute, ownUser, subscriptions }: BackgroundData, element: HeaderMessageListElement, ): string => { const { subsequentMessage: message, style: headerStyle } = element; @@ -41,6 +42,7 @@ export default ( const streamName = streamNameOfStreamMessage(message); const topicNarrowStr = keyFromNarrow(topicNarrow(message.stream_id, message.subject)); const topicHtml = renderTopic(message); + const isFollowed = isTopicFollowed(message.stream_id, message.subject, mute); if (headerStyle === 'topic+date') { return template`\ @@ -49,7 +51,7 @@ export default ( data-narrow="${base64Utf8Encode(topicNarrowStr)}" data-msg-id="${message.id}" > -
$!${topicHtml}
+
$!${topicHtml}
${humanDate(new Date(message.timestamp * 1000))}
`; } else if (headerStyle === 'full') { @@ -70,7 +72,7 @@ export default ( data-narrow="${base64Utf8Encode(streamNarrowStr)}"> # ${streamName}
-
$!${topicHtml}
+
$!${topicHtml}
${humanDate(new Date(message.timestamp * 1000))}
`; } else { diff --git a/src/webview/static/base.css b/src/webview/static/base.css index 731c97371e5..673b8c369c6 100644 --- a/src/webview/static/base.css +++ b/src/webview/static/base.css @@ -116,10 +116,22 @@ body { .topic-text { flex: 1; padding: 0 8px; + display: flex; + align-items: center; overflow: hidden; text-overflow: ellipsis; pointer-events: none; } +.topic-text[data-followed="true"]::after { + content: ""; + background-image: url("images/follow.svg"); + margin-left: 12px; + width: 17px; + height: 17px; + /* opacity: 0.2 on web, but that's with the pastel stream colors; + * 0.3 stands up better to our gray. */ + opacity: 0.3; +} .topic-date { opacity: 0.5; padding: 0 8px;