Skip to content

Commit

Permalink
Pinned guild messages improvements (#348)
Browse files Browse the repository at this point in the history
- Style fixes (now works when improved messages style off)
- Console log message if no authorization to pin a message
- Pinned messages will not appear if no other guild messages are shown (as a way to recognize if the messages folder is irrelevant to guild messages)
  • Loading branch information
GreatApo committed Jun 26, 2022
1 parent 741b113 commit 6ccb809
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions source/core/resources/style_gca.css
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,8 @@
.gca_messages_styling .gca_messages_other_news .message_text,
.gca_messages_styling .gca_messages_other_news .message_footer{background: #EAD791!important;}

/* Guild pinned message */
.gca_messages_pinned_message .messageSubject{background: #EAD791!important;height: 14px;width: 508px;padding: 4px 4px 4px 0px;border-width: 1px;}


/* New Message Layout
Expand Down
6 changes: 4 additions & 2 deletions source/core/source/guild.baths.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ var gca_guild_baths = {
// Check if admin by checking if you can delete all messages
let numberOfMessages = document.getElementById('content').getElementsByTagName('tr').length/4;
let links = document.getElementById('content').getElementsByTagName('a');
numberOfDeleteLinks = 0;
let numberOfDeleteLinks = 0;
for (var i=0; i<links.length; i++) {
let href = links[i].getAttribute('href');
if ( href.match('&den=') )
numberOfDeleteLinks++;
}
if(numberOfMessages > numberOfDeleteLinks)
if(numberOfMessages > numberOfDeleteLinks){
console.log('[GCA] Not authorized to pin messages');
return;
}

// Add pinned announcement button
let button = document.createElement('input');
Expand Down
7 changes: 6 additions & 1 deletion source/core/source/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,13 @@ var gca_messages = {
if(message==null) return;
let sender = gca_data.section.get('cache', 'guild_pinned_message_sender', null);

// Show pinned guild message only if other guild messages are shown (avoid showing the message in folder unrelated to guild)
if(gca_messages.messages.type["guild"].length==0)
return;

// Display pinned message
let pinned_message_container = document.createElement("div");
pinned_message_container.className = "message_box gca_messages_other_news";
pinned_message_container.className = "message_box gca_messages_pinned_message";

let subject_box = document.createElement("div");
subject_box.className = "messageSubject";
Expand Down

0 comments on commit 6ccb809

Please sign in to comment.