|
@@ -5,6 +5,7 @@ import { debounce } from 'throttle-debounce';
|
|
|
|
|
|
|
|
import { apiv3Put } from '~/client/util/apiv3-client';
|
|
import { apiv3Put } from '~/client/util/apiv3-client';
|
|
|
import { IUserUISettings } from '~/interfaces/user-ui-settings';
|
|
import { IUserUISettings } from '~/interfaces/user-ui-settings';
|
|
|
|
|
+import { useIsGuestUser } from '~/stores/context';
|
|
|
|
|
|
|
|
let settingsForBulk: Partial<IUserUISettings> = {};
|
|
let settingsForBulk: Partial<IUserUISettings> = {};
|
|
|
const _putUserUISettingsInBulk = (): Promise<AxiosResponse<IUserUISettings>> => {
|
|
const _putUserUISettingsInBulk = (): Promise<AxiosResponse<IUserUISettings>> => {
|
|
@@ -18,7 +19,8 @@ const _putUserUISettingsInBulk = (): Promise<AxiosResponse<IUserUISettings>> =>
|
|
|
|
|
|
|
|
const _putUserUISettingsInBulkDebounced = debounce(1500, false, _putUserUISettingsInBulk);
|
|
const _putUserUISettingsInBulkDebounced = debounce(1500, false, _putUserUISettingsInBulk);
|
|
|
|
|
|
|
|
-export const scheduleToPutUserUISettings = (settings: Partial<IUserUISettings>): Promise<AxiosResponse<IUserUISettings>> => {
|
|
|
|
|
|
|
+type ScheduleToPutFunction = (settings: Partial<IUserUISettings>) => Promise<AxiosResponse<IUserUISettings>>;
|
|
|
|
|
+const scheduleToPut: ScheduleToPutFunction = (settings: Partial<IUserUISettings>): Promise<AxiosResponse<IUserUISettings>> => {
|
|
|
settingsForBulk = {
|
|
settingsForBulk = {
|
|
|
...settingsForBulk,
|
|
...settingsForBulk,
|
|
|
...settings,
|
|
...settings,
|
|
@@ -26,3 +28,16 @@ export const scheduleToPutUserUISettings = (settings: Partial<IUserUISettings>):
|
|
|
|
|
|
|
|
return _putUserUISettingsInBulkDebounced();
|
|
return _putUserUISettingsInBulkDebounced();
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+type UserUISettingsUtil = {
|
|
|
|
|
+ scheduleToPut: ScheduleToPutFunction | (() => void),
|
|
|
|
|
+}
|
|
|
|
|
+export const useUserUISettings = (): UserUISettingsUtil => {
|
|
|
|
|
+ const { data: isGuestUser } = useIsGuestUser();
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ scheduleToPut: isGuestUser
|
|
|
|
|
+ ? () => {}
|
|
|
|
|
+ : scheduleToPut,
|
|
|
|
|
+ };
|
|
|
|
|
+};
|