stream-chat-react-native-core
Version:
The official React Native and Expo components for Stream Chat, a service for building chat applications
31 lines (24 loc) • 793 B
text/typescript
import type { SharedLocationResponse } from 'stream-chat';
import { mapSharedLocationToStorable } from '../mappers/mapSharedLocationToStorable';
import { createUpsertQuery } from '../sqlite-utils/createUpsertQuery';
import { SqliteClient } from '../SqliteClient';
import type { PreparedQueries } from '../types';
export const upsertLocation = async ({
execute = true,
location,
}: {
location: SharedLocationResponse;
execute?: boolean;
}) => {
const queries: PreparedQueries[] = [];
queries.push(createUpsertQuery('locations', mapSharedLocationToStorable(location)));
SqliteClient.logger?.('info', 'upsertLocation', {
cid: location.channel_cid,
execute,
location,
});
if (execute) {
await SqliteClient.executeSqlBatch(queries);
}
return queries;
};