* Add announcement banner * Move config to its own table * Add new config behaviour to iOS share extensions * Fix test * Add style changes * Minor style fixes * Address design feedback * Address feedback * Only render the announcement banner if container if licensed Co-authored-by: Daniel Espino <danielespino@MacBook-Pro-de-Daniel.local>
39 lines
1.6 KiB
TypeScript
39 lines
1.6 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider';
|
|
import withObservables from '@nozbe/with-observables';
|
|
import {of as of$, combineLatest} from 'rxjs';
|
|
import {switchMap} from 'rxjs/operators';
|
|
|
|
import {observeConfigBooleanValue, observeConfigValue, observeLastDismissedAnnouncement, observeLicense} from '@queries/servers/system';
|
|
|
|
import AnnouncementBanner from './announcement_banner';
|
|
|
|
import type {WithDatabaseArgs} from '@typings/database/database';
|
|
|
|
const enhanced = withObservables([], ({database}: WithDatabaseArgs) => {
|
|
const lastDismissed = observeLastDismissedAnnouncement(database);
|
|
const bannerText = observeConfigValue(database, 'BannerText');
|
|
const allowDismissal = observeConfigBooleanValue(database, 'AllowBannerDismissal');
|
|
|
|
const bannerDismissed = combineLatest([lastDismissed, bannerText, allowDismissal]).pipe(
|
|
switchMap(([ld, bt, abd]) => of$(abd && (ld === bt))),
|
|
);
|
|
|
|
const license = observeLicense(database);
|
|
const enableBannerConfig = observeConfigBooleanValue(database, 'EnableBanner');
|
|
const bannerEnabled = combineLatest([license, enableBannerConfig]).pipe(
|
|
switchMap(([lcs, cfg]) => of$(cfg && lcs?.IsLicensed === 'true')),
|
|
);
|
|
return {
|
|
bannerColor: observeConfigValue(database, 'BannerColor'),
|
|
bannerEnabled,
|
|
bannerText,
|
|
bannerTextColor: observeConfigValue(database, 'BannerTextColor'),
|
|
bannerDismissed,
|
|
allowDismissal,
|
|
};
|
|
});
|
|
|
|
export default withDatabase(enhanced(AnnouncementBanner));
|