Simplify client code that reads the user preferences
Use Gerrit.getUserPeferences() instead of Gerrit.getUserAccount().getGeneralPreferences() The first one returns the client side representation of the user settings (AccountPreferencesInfo) while the second one returns the entity class for persisting the user preferences in the database (AccountGeneralPreferences). Gerrit.getUserPreferences() never returns null. If the user is not signed in the default preferences are returned. Hence we no longer need to check with Gerrit.isSignedIn() whether the user is signed in whenever we access the user preferences. Change-Id: I6420c221f66299485d0cd913a55563b0cd2a9b11 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -59,7 +59,11 @@ public class AccountPreferencesInfo extends JavaScriptObject {
|
||||
}
|
||||
|
||||
public final short changesPerPage() {
|
||||
return get("changes_per_page", AccountGeneralPreferences.DEFAULT_PAGESIZE);
|
||||
short changesPerPage =
|
||||
get("changes_per_page", AccountGeneralPreferences.DEFAULT_PAGESIZE);
|
||||
return 0 < changesPerPage
|
||||
? changesPerPage
|
||||
: AccountGeneralPreferences.DEFAULT_PAGESIZE;
|
||||
}
|
||||
private final native short get(String n, int d)
|
||||
/*-{ return this.hasOwnProperty(n) ? this[n] : d }-*/;
|
||||
|
||||
Reference in New Issue
Block a user