Gekidou Android share extension (#6803)

* Refactor app database queries to not require the app database as argument

* Android Share Extension and fix notifications prompt

* feedback review
This commit is contained in:
Elias Nahum
2022-11-30 23:18:56 +02:00
committed by GitHub
parent c1f480de31
commit 6eadc527bb
86 changed files with 4116 additions and 383 deletions

View File

@@ -18,7 +18,7 @@ import {fetchUsersByIds, updateUsersNoLongerVisible} from '@actions/remote/user'
import {loadCallForChannel} from '@calls/actions/calls';
import {Events, Screens} from '@constants';
import DatabaseManager from '@database/manager';
import {queryActiveServer} from '@queries/app/servers';
import {getActiveServer} from '@queries/app/servers';
import {deleteChannelMembership, getChannelById, prepareMyChannelsForTeam, getCurrentChannel} from '@queries/servers/channel';
import {prepareCommonSystemValues, getConfig, setCurrentChannelId, getCurrentChannelId, getCurrentTeamId} from '@queries/servers/system';
import {getNthLastChannelFromTeam} from '@queries/servers/team';
@@ -356,7 +356,7 @@ export async function handleUserRemovedFromChannelEvent(serverUrl: string, msg:
if (user.id === userId) {
await removeCurrentUserFromChannel(serverUrl, channelId);
if (channel && channel.id === channelId) {
const currentServer = await queryActiveServer(DatabaseManager.appDatabase!.database);
const currentServer = await getActiveServer();
if (currentServer?.url === serverUrl) {
DeviceEventEmitter.emit(Events.LEAVE_CHANNEL, channel.displayName);
@@ -431,7 +431,7 @@ export async function handleChannelDeletedEvent(serverUrl: string, msg: WebSocke
await removeCurrentUserFromChannel(serverUrl, channelId);
if (currentChannel && currentChannel.id === channelId) {
const currentServer = await queryActiveServer(DatabaseManager.appDatabase!.database);
const currentServer = await getActiveServer();
if (currentServer?.url === serverUrl) {
DeviceEventEmitter.emit(Events.CHANNEL_ARCHIVED, currentChannel.displayName);

View File

@@ -31,7 +31,7 @@ import {Events, Screens, WebsocketEvents} from '@constants';
import {SYSTEM_IDENTIFIERS} from '@constants/database';
import DatabaseManager from '@database/manager';
import AppsManager from '@managers/apps_manager';
import {getActiveServerUrl, queryActiveServer} from '@queries/app/servers';
import {getActiveServerUrl, getActiveServer} from '@queries/app/servers';
import {getCurrentChannel} from '@queries/servers/channel';
import {
getConfig,
@@ -135,7 +135,7 @@ async function doReconnect(serverUrl: string) {
const currentTeam = await getCurrentTeam(database);
const currentChannel = await getCurrentChannel(database);
const currentActiveServerUrl = await getActiveServerUrl(DatabaseManager.appDatabase!.database);
const currentActiveServerUrl = await getActiveServerUrl();
const entryData = await entry(serverUrl, currentTeam?.id, currentChannel?.id, lastDisconnectedAt);
if ('error' in entryData) {
@@ -150,7 +150,7 @@ async function doReconnect(serverUrl: string) {
// if no longer a member of the current team or the current channel
if (initialTeamId !== currentTeam?.id || initialChannelId !== currentChannel?.id) {
const currentServer = await queryActiveServer(appDatabase);
const currentServer = await getActiveServer();
const isChannelScreenMounted = NavigationStore.getNavigationComponents().includes(Screens.CHANNEL);
if (serverUrl === currentServer?.url) {
if (currentTeam && initialTeamId !== currentTeam.id) {

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import DatabaseManager from '@database/manager';
import IntegrationsManager from '@managers/integrations_manager';
import {getActiveServerUrl} from '@queries/app/servers';
@@ -9,14 +9,10 @@ export async function handleOpenDialogEvent(serverUrl: string, msg: WebSocketMes
if (!data) {
return;
}
const appDatabase = DatabaseManager.appDatabase?.database;
if (!appDatabase) {
return;
}
try {
const dialog: InteractiveDialogConfig = JSON.parse(data);
const currentServer = await getActiveServerUrl(appDatabase);
const currentServer = await getActiveServerUrl();
if (currentServer === serverUrl) {
IntegrationsManager.getManager(serverUrl).setDialog(dialog);
}

View File

@@ -41,11 +41,7 @@ export async function handleLeaveTeamEvent(serverUrl: string, msg: WebSocketMess
}
if (currentTeam?.id === teamId) {
const appDatabase = DatabaseManager.appDatabase?.database;
let currentServer = '';
if (appDatabase) {
currentServer = await getActiveServerUrl(appDatabase);
}
const currentServer = await getActiveServerUrl();
if (currentServer === serverUrl) {
DeviceEventEmitter.emit(Events.LEAVE_TEAM, currentTeam?.displayName);