Skip to content

Commit

Permalink
Use constant instead of using literal 'UNREAD'
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavminhas committed Jul 29, 2024
1 parent 3030a24 commit bc14a60
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions GmailAPIHelper/GmailHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static class GmailHelper
private static List<string> _scopes;
private static string _applicationName;
private const string _tokenFile = "token.json";
private const string _labelUnread = "UNREAD";

/// <summary>
/// 'Token Path Type' enum.
Expand Down Expand Up @@ -198,7 +199,7 @@ public static Message GetMessage(this GmailService gmailService, string query, b
requiredLatestMessage = messageRequest.Execute();
if (markRead)
{
var labelToRemove = new List<string> { "UNREAD" };
var labelToRemove = new List<string> { _labelUnread };
service.RemoveLabels(requiredLatestMessage.Id, labelToRemove, userId: userId);
}
}
Expand Down Expand Up @@ -245,7 +246,7 @@ public static List<Message> GetMessages(this GmailService gmailService, string q
messages.Add(currentMessage);
if (markRead)
{
var labelToRemove = new List<string> { "UNREAD" };
var labelToRemove = new List<string> { _labelUnread };
service.RemoveLabels(message.Id, labelToRemove, userId: userId);
}
}
Expand Down Expand Up @@ -313,7 +314,7 @@ public static string GetLatestMessage(this GmailService gmailService, string que
requiredMessage = Encoding.UTF8.GetString(data);
if (markRead)
{
var labelToRemove = new List<string> { "UNREAD" };
var labelToRemove = new List<string> { _labelUnread };
service.RemoveLabels(latestMessage.Id, labelToRemove, userId: userId);
}
}
Expand Down Expand Up @@ -968,7 +969,7 @@ public static bool MarkMessageAsRead(this GmailService gmailService, string quer
{
var mods = new ModifyMessageRequest
{
RemoveLabelIds = new List<string> { "UNREAD" }
RemoveLabelIds = new List<string> { _labelUnread }
};
var service = gmailService;
List<Message> result = new List<Message>();
Expand Down Expand Up @@ -1020,7 +1021,7 @@ public static int MarkMessagesAsRead(this GmailService gmailService, string quer
{
var mods = new ModifyMessageRequest
{
RemoveLabelIds = new List<string> { "UNREAD" }
RemoveLabelIds = new List<string> { _labelUnread }
};
int counter = 0;
var service = gmailService;
Expand Down Expand Up @@ -1057,7 +1058,7 @@ public static bool MarkMessageAsUnread(this GmailService gmailService, string qu
{
var mods = new ModifyMessageRequest
{
AddLabelIds = new List<string> { "UNREAD" }
AddLabelIds = new List<string> { _labelUnread }
};
var service = gmailService;
List<Message> result = new List<Message>();
Expand Down Expand Up @@ -1109,7 +1110,7 @@ public static int MarkMessagesAsUnread(this GmailService gmailService, string qu
{
var mods = new ModifyMessageRequest
{
AddLabelIds = new List<string> { "UNREAD" }
AddLabelIds = new List<string> { _labelUnread }
};
int counter = 0;
var service = gmailService;
Expand Down

0 comments on commit bc14a60

Please sign in to comment.