5180 fichiers 38.5 Mo 0 téléchargements 231 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / hooks / catalog / catalogNewAdditionsStore.ts
catalogNewAdditionsStore.ts 1.8 Ko Télécharger le fichier
import { createOctaneStore } from '../../state/createOctaneStore';

/** AIR `CatalogPageName.CATALOG_PAGE_NEW_ADDITIONS`. */
export const CATALOG_PAGE_NEW_ADDITIONS = 'new_additions';

export interface CatalogNewAdditionsState {
    /** The normal catalogue index flagged new additions (`newAdditionsAvailable`) and the catalogue has not opened since. */
    available: boolean;
    setAvailable: (available: boolean) => void;
}

export const useCatalogNewAdditionsStore = createOctaneStore<CatalogNewAdditionsState>((set) => ({
    available: false,
    setAvailable: (available) => set({ available })
}));

export interface NewAdditionsOpenContext {
    /** The index flag is set. */
    available: boolean;
    /** The catalogue opens on a page of its own (deep link, offer, the page it showed last). */
    hasTarget: boolean;
    /** `toolbar.new_additions.notification.enabled`. */
    notificationEnabled: boolean;
    /** `catalog.new.additions.page.open.disabled`. */
    openDisabled: boolean;
}

export interface NewAdditionsOpenResult {
    /** Send MarkCatalogNewAdditionsPageOpened, clear the flag and hide the toolbar label (CATALOG_NEW_ITEMS_HIDE). */
    mark: boolean;
    /** Open the new_additions page instead of the front page. */
    openNewAdditions: boolean;
}

/**
 * AIR `HabboCatalog`: with the flag set, a catalogue that opens without a page of its own opens the new_additions page
 * (only while the toolbar notification is on and the page open is not disabled), and opening the catalogue marks the
 * page as seen, which hides the label.
 */
export const resolveNewAdditionsOnOpen = (context: NewAdditionsOpenContext): NewAdditionsOpenResult => ({
    mark: context.available,
    openNewAdditions: context.available && !context.hasTarget && context.notificationEnabled && !context.openDisabled
});
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser