This commit is contained in:
harshil Sharma 2023-11-01 18:15:05 +05:30
parent 3555eb5d72
commit bf2fd6594d
7 changed files with 18 additions and 3 deletions

View file

@ -29,6 +29,7 @@ export const deleteCategory = async (serverUrl: string, categoryId: string) => {
}
};
// LOL use this
export async function storeCategories(serverUrl: string, categories: CategoryWithChannels[], prune = false, prepareRecordsOnly = false) {
try {
const {operator} = DatabaseManager.getServerDatabaseAndOperator(serverUrl);

View file

@ -231,6 +231,8 @@ export async function createChannel(serverUrl: string, displayName: string, purp
const resolvedModels = await Promise.all(channelModels);
models.push(...resolvedModels.flat());
}
// LOL
const categoriesModels = await addChannelToDefaultCategory(serverUrl, channelData, true);
if (categoriesModels.models?.length) {
models.push(...categoriesModels.models);

View file

@ -44,6 +44,7 @@ export async function handleCategoryCreatedEvent(serverUrl: string, msg: Websock
}
}
// LOL
export async function handleCategoryUpdatedEvent(serverUrl: string, msg: WebsocketCategoriesMessage) {
let categories;

View file

@ -34,6 +34,10 @@ export const queryCategoriesByTeamIds = (database: Database, teamIds: string[])
return database.get<CategoryModel>(CATEGORY).query(Q.where('team_id', Q.oneOf(teamIds)));
};
export const queryAllCategories = (database: Database) => {
return database.get<CategoryModel>(CATEGORY).query();
};
export async function prepareCategoriesAndCategoriesChannels(operator: ServerDataOperator, categories: CategoryWithChannels[], prune = false) {
try {
const {database} = operator;

View file

@ -7,9 +7,8 @@ import {fetchChannelMemberships, getGroupMessageMembersCommonTeams} from '@actio
import {PER_PAGE_DEFAULT} from '@app/client/rest/constants';
import {useServerUrl} from '@app/context/server';
import {ConvertGMToChannelForm} from './convert_gm_to_channel_form/convert_gm_to_channel_form';
import ConvertGMToChannelForm from './convert_gm_to_channel_form';
import {Loader} from './loader';
import channel from '@app/constants/channel';
type Props = {
channelId: string;

View file

@ -36,7 +36,7 @@ type Props = {
commonTeams: Team[];
profiles: UserProfile[];
locale?: string;
teammateNameDisplay: string;
teammateNameDisplay?: string;
}
export const ConvertGMToChannelForm = ({

View file

@ -6,13 +6,16 @@ import {switchMap, distinctUntilChanged} from '@nozbe/watermelondb/utils/rx';
import withObservables from '@nozbe/with-observables';
import {of as of$} from 'rxjs';
import {queryAllCategories} from '@app/queries/servers/categories';
import {observeCurrentUser, observeTeammateNameDisplay} from '@app/queries/servers/user';
import {logDebug} from '@app/utils/log';
import {ConvertGMToChannelForm} from './convert_gm_to_channel_form';
import type {WithDatabaseArgs} from '@typings/database/database';
const enhanced = withObservables([], ({database}: WithDatabaseArgs) => {
logDebug('CCCCCCCCCCC');
const locale = observeCurrentUser(database).pipe(
switchMap((user) => of$(user?.locale)),
distinctUntilChanged(),
@ -20,6 +23,11 @@ const enhanced = withObservables([], ({database}: WithDatabaseArgs) => {
const teammateNameDisplay = observeTeammateNameDisplay(database);
logDebug('AAAAAAAAAAAAAAAAAAAAAA');
const allCategories = queryAllCategories(database);
logDebug(allCategories);
return {
locale,
teammateNameDisplay,