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

feat: support for the new slack ui #425

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion recipes/slack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "slack",
"name": "Slack",
"version": "1.5.0",
"version": "1.6.0",
"license": "MIT",
"config": {
"serviceURL": "https://{teamId}.slack.com",
Expand Down
17 changes: 14 additions & 3 deletions recipes/slack/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,23 @@ module.exports = Ferdium => {
const getTeamIcon = function getTeamIcon(count = 0) {
let countTeamIconCheck = count;
let bgUrl = null;
const teamMenu = document.querySelector(
// INFO: A new Slack UI was introduced in August 2023 and will be rolled out gradually,
// therefore we need to support both old and new UI for the time being
// See more: https://slack.com/blog/productivity/a-redesigned-slack-built-for-focus
const oldSlackUiTeamMenu = document.querySelector(
'#team-menu-trigger, .p-ia__sidebar_header__team_name',
);
const newSlackUiTeamMenu = document.querySelector(
'.p-ia4_home_header_menu__button',
);

if (oldSlackUiTeamMenu || newSlackUiTeamMenu) {
if (oldSlackUiTeamMenu) {
oldSlackUiTeamMenu.click();
} else if (newSlackUiTeamMenu) {
newSlackUiTeamMenu.click();
}
Comment on lines +44 to +56
Copy link
Member

Choose a reason for hiding this comment

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

Haven't tested it (I don't use slack). But instead of this, can't we use an array of strings on which we pass all the query selectors (old and new)? Given that the logic for both new and old just vary on the query selector?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how that would look like, feel free to push a commit simplifying this!

I wasn't planning on keeping this code around for the long run and remove the old slack UI code in a couple of months.

Copy link
Member

Choose a reason for hiding this comment

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

Lets go with your fix and then change it in a couple of months (when the new UI sticks) 😄 Thank you!


if (teamMenu) {
teamMenu.click();
const icon = document.querySelector('.c-team_icon');

if (icon) {
Expand Down