Skip to content

Commit

Permalink
Remove default_sort_order (#2256)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinnDevelopment authored Sep 20, 2022
1 parent f7ac0e7 commit 6b8424d
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 161 deletions.
14 changes: 7 additions & 7 deletions src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ public enum AuditLogKey
*/
CHANNEL_AVAILABLE_TAGS("available_tags"),

/**
* The {@link ForumChannel#getDefaultSortOrder()} value.
* <br>Only for {@link ChannelType#FORUM}.
*
* <p>Expected type: <b>Integer</b>
*/
CHANNEL_DEFAULT_SORT_ORDER("default_sort_order"),
// /**
// * The {@link ForumChannel#getDefaultSortOrder()} value.
// * <br>Only for {@link ChannelType#FORUM}.
// *
// * <p>Expected type: <b>Integer</b>
// */
// CHANNEL_DEFAULT_SORT_ORDER("default_sort_order"),

// THREADS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,15 @@ public enum ChannelField
*/
APPLIED_TAGS("applied_tags", AuditLogKey.THREAD_APPLIED_TAGS),

/**
* The default sort order of a forum channel.
*
* <p>Limited to {@link ForumChannel Forum Channels}.
*
* @see ForumChannel#getDefaultSortOrder()
*/
DEFAULT_SORT_ORDER("default_sort_order", AuditLogKey.CHANNEL_DEFAULT_SORT_ORDER);
// /**
// * The default sort order of a forum channel.
// *
// * <p>Limited to {@link ForumChannel Forum Channels}.
// *
// * @see ForumChannel#getDefaultSortOrder()
// */
// DEFAULT_SORT_ORDER("default_sort_order", AuditLogKey.CHANNEL_DEFAULT_SORT_ORDER)
;

private final String fieldName;
private final AuditLogKey auditLogKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ default boolean isTagRequired()
@Nullable
EmojiUnion getDefaultReaction();

/**
* The default order used to show threads.
*
* @return The default order used to show threads.
*/
@Nonnull
SortOrder getDefaultSortOrder();
// /**
// * The default order used to show threads.
// *
// * @return The default order used to show threads.
// */
// @Nonnull
// SortOrder getDefaultSortOrder();

/**
* Creates a new forum post (thread) in this forum.
Expand Down Expand Up @@ -243,60 +243,60 @@ default boolean isTagRequired()
@CheckReturnValue
ForumPostAction createForumPost(@Nonnull String name, @Nonnull MessageCreateData message);

/**
* The order used to sort forum posts.
*/
enum SortOrder
{
/**
* Sort by recent activity, including unarchive, message, reaction, and thread creation.
*/
RECENT_ACTIVITY(0),
/**
* Sort by the time the post was originally created.
*/
CREATION_TIME(1),
/**
* Placeholder for possible future order modes.
*/
UNKNOWN(-1),
;

private final int order;

SortOrder(int order)
{
this.order = order;
}

/**
* The underlying value as used by Discord.
*
* @return The raw order key
*/
public int getKey()
{
return order;
}

/**
* The {@link SortOrder} for the provided key.
*
* @param key
* The key to get the {@link SortOrder} for
*
* @return The {@link SortOrder} for the provided key, or {@link #UNKNOWN} if the key is not known
*/
@Nonnull
public static SortOrder fromKey(int key)
{
for (SortOrder order : values())
{
if (order.order == key)
return order;
}

return UNKNOWN;
}
}
// /**
// * The order used to sort forum posts.
// */
// enum SortOrder
// {
// /**
// * Sort by recent activity, including unarchive, message, reaction, and thread creation.
// */
// RECENT_ACTIVITY(0),
// /**
// * Sort by the time the post was originally created.
// */
// CREATION_TIME(1),
// /**
// * Placeholder for possible future order modes.
// */
// UNKNOWN(-1),
// ;
//
// private final int order;
//
// SortOrder(int order)
// {
// this.order = order;
// }
//
// /**
// * The underlying value as used by Discord.
// *
// * @return The raw order key
// */
// public int getKey()
// {
// return order;
// }
//
// /**
// * The {@link SortOrder} for the provided key.
// *
// * @param key
// * The key to get the {@link SortOrder} for
// *
// * @return The {@link SortOrder} for the provided key, or {@link #UNKNOWN} if the key is not known
// */
// @Nonnull
// public static SortOrder fromKey(int key)
// {
// for (SortOrder order : values())
// {
// if (order.order == key)
// return order;
// }
//
// return UNKNOWN;
// }
// }
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void onChannelUpdateRegion(@Nonnull ChannelUpdateRegionEvent event) {}
public void onChannelUpdateSlowmode(@Nonnull ChannelUpdateSlowmodeEvent event) {}
public void onChannelUpdateDefaultThreadSlowmode(@Nonnull ChannelUpdateDefaultThreadSlowmodeEvent event) {}
public void onChannelUpdateDefaultReaction(@Nonnull ChannelUpdateDefaultReactionEvent event) {}
public void onChannelUpdateDefaultSortOrder(@Nonnull ChannelUpdateDefaultSortOrderEvent event) {}
// public void onChannelUpdateDefaultSortOrder(@Nonnull ChannelUpdateDefaultSortOrderEvent event) {}
public void onChannelUpdateTopic(@Nonnull ChannelUpdateTopicEvent event) {}
public void onChannelUpdateType(@Nonnull ChannelUpdateTypeEvent event) {}
public void onChannelUpdateUserLimit(@Nonnull ChannelUpdateUserLimitEvent event) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ public ForumChannel createForumChannel(GuildImpl guild, DataObject json, long gu
.setParentCategory(json.getLong("parent_id", 0))
.setFlags(json.getInt("flags", 0))
.setDefaultReaction(json.optObject("default_reaction_emoji").orElse(null))
.setDefaultSortOrder(json.getInt("default_sort_order", -1))
// .setDefaultSortOrder(json.getInt("default_sort_order", -1))
.setName(json.getString("name"))
.setTopic(json.getString("topic", null))
.setPosition(json.getInt("position"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class ForumChannelImpl extends AbstractGuildChannelImpl<ForumChannelImpl>
private int position;
private int flags;
private int slowmode;
private int defaultSortOrder;
// private int defaultSortOrder;
protected int defaultThreadSlowmode;

public ForumChannelImpl(long id, GuildImpl guild)
Expand Down Expand Up @@ -187,12 +187,12 @@ public int getDefaultThreadSlowmode()
return defaultThreadSlowmode;
}

@Nonnull
@Override
public SortOrder getDefaultSortOrder()
{
return SortOrder.fromKey(defaultSortOrder);
}
// @Nonnull
// @Override
// public SortOrder getDefaultSortOrder()
// {
// return SortOrder.fromKey(defaultSortOrder);
// }

@Nonnull
@Override
Expand Down Expand Up @@ -221,10 +221,10 @@ public int getRawFlags()
return flags;
}

public int getRawSortOrder()
{
return defaultSortOrder;
}
// public int getRawSortOrder()
// {
// return defaultSortOrder;
// }

// Setters

Expand Down Expand Up @@ -284,9 +284,9 @@ else if (emoji != null && !emoji.isNull("emoji_name"))
return this;
}

public ForumChannelImpl setDefaultSortOrder(int defaultSortOrder)
{
this.defaultSortOrder = defaultSortOrder;
return this;
}
// public ForumChannelImpl setDefaultSortOrder(int defaultSortOrder)
// {
// this.defaultSortOrder = defaultSortOrder;
// return this;
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
import net.dv8tion.jda.api.entities.channel.ChannelFlag;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer;
import net.dv8tion.jda.api.entities.channel.concrete.*;
import net.dv8tion.jda.api.entities.channel.concrete.Category;
import net.dv8tion.jda.api.entities.channel.concrete.NewsChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
import net.dv8tion.jda.api.entities.channel.forums.ForumTag;
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
import net.dv8tion.jda.api.entities.emoji.EmojiUnion;
Expand Down Expand Up @@ -191,7 +194,7 @@ protected Long handleInternally(DataObject content)

ForumChannelImpl forumChannel = (ForumChannelImpl) channel;
content.optArray("available_tags").ifPresent(array -> handleTagsUpdate(forumChannel, array));
int sortOrder = content.getInt("default_sort_order", ((ForumChannelImpl) channel).getRawSortOrder());
// int sortOrder = content.getInt("default_sort_order", ((ForumChannelImpl) channel).getRawSortOrder());

//If any properties changed, update the values and fire the proper events.
final long oldParentId = forumChannel.getParentCategoryIdLong();
Expand All @@ -202,7 +205,7 @@ protected Long handleInternally(DataObject content)
final int oldSlowmode = forumChannel.getSlowmode();
final int oldDefaultThreadSlowmode = forumChannel.getDefaultThreadSlowmode();
final int oldFlags = forumChannel.getRawFlags();
final int oldSortOrder = forumChannel.getRawSortOrder();
// final int oldSortOrder = forumChannel.getRawSortOrder();
final EmojiUnion oldDefaultReaction = forumChannel.getDefaultReaction();

if (!Objects.equals(oldName, name))
Expand Down Expand Up @@ -278,14 +281,14 @@ protected Long handleInternally(DataObject content)
getJDA(), responseNumber,
forumChannel, oldDefaultReaction, defaultReaction));
}
if (oldSortOrder != sortOrder)
{
forumChannel.setDefaultSortOrder(sortOrder);
getJDA().handleEvent(
new ChannelUpdateDefaultSortOrderEvent(
getJDA(), responseNumber,
forumChannel, ForumChannel.SortOrder.fromKey(oldSortOrder), ForumChannel.SortOrder.fromKey(sortOrder)));
}
// if (oldSortOrder != sortOrder)
// {
// forumChannel.setDefaultSortOrder(sortOrder);
// getJDA().handleEvent(
// new ChannelUpdateDefaultSortOrderEvent(
// getJDA(), responseNumber,
// forumChannel, ForumChannel.SortOrder.fromKey(oldSortOrder), ForumChannel.SortOrder.fromKey(sortOrder)));
// }
break;
}
case NEWS:
Expand Down

0 comments on commit 6b8424d

Please sign in to comment.