diff --git a/app/lib/database/model/Subscription.js b/app/lib/database/model/Subscription.js
index 37bab8c08..ba928da6e 100644
--- a/app/lib/database/model/Subscription.js
+++ b/app/lib/database/model/Subscription.js
@@ -50,6 +50,8 @@ export default class Subscription extends Model {
@field('announcement') announcement;
+ @field('banner_closed') bannerClosed;
+
@field('topic') topic;
@field('blocked') blocked;
diff --git a/app/lib/database/model/migrations.js b/app/lib/database/model/migrations.js
index c8d815245..93414ab0d 100644
--- a/app/lib/database/model/migrations.js
+++ b/app/lib/database/model/migrations.js
@@ -74,6 +74,17 @@ export default schemaMigrations({
]
})
]
+ },
+ {
+ toVersion: 8,
+ steps: [
+ addColumns({
+ table: 'subscriptions',
+ columns: [
+ { name: 'banner_closed', type: 'boolean', isOptional: true }
+ ]
+ })
+ ]
}
]
});
diff --git a/app/lib/database/schema/app.js b/app/lib/database/schema/app.js
index a16cb547d..dbd7a232c 100644
--- a/app/lib/database/schema/app.js
+++ b/app/lib/database/schema/app.js
@@ -1,7 +1,7 @@
import { appSchema, tableSchema } from '@nozbe/watermelondb';
export default appSchema({
- version: 7,
+ version: 8,
tables: [
tableSchema({
name: 'subscriptions',
@@ -25,6 +25,7 @@ export default appSchema({
{ name: 'last_message', type: 'string', isOptional: true },
{ name: 'description', type: 'string', isOptional: true },
{ name: 'announcement', type: 'string', isOptional: true },
+ { name: 'banner_closed', type: 'boolean', isOptional: true },
{ name: 'topic', type: 'string', isOptional: true },
{ name: 'blocked', type: 'boolean', isOptional: true },
{ name: 'blocker', type: 'boolean', isOptional: true },
diff --git a/app/lib/methods/helpers/findSubscriptionsRooms.js b/app/lib/methods/helpers/findSubscriptionsRooms.js
index 9773c5f7d..a0a9c5c22 100644
--- a/app/lib/methods/helpers/findSubscriptionsRooms.js
+++ b/app/lib/methods/helpers/findSubscriptionsRooms.js
@@ -27,6 +27,7 @@ export default async(subscriptions = [], rooms = []) => {
lastOpen: s.lastOpen,
description: s.description,
announcement: s.announcement,
+ bannerClosed: s.bannerClosed,
topic: s.topic,
blocked: s.blocked,
blocker: s.blocker,
diff --git a/app/lib/methods/subscriptions/rooms.js b/app/lib/methods/subscriptions/rooms.js
index 85e0ac3a9..da1b50d95 100644
--- a/app/lib/methods/subscriptions/rooms.js
+++ b/app/lib/methods/subscriptions/rooms.js
@@ -57,6 +57,7 @@ const createOrUpdateSubscription = async(subscription, room) => {
lastOpen: s.lastOpen,
description: s.description,
announcement: s.announcement,
+ bannerClosed: s.bannerClosed,
topic: s.topic,
blocked: s.blocked,
blocker: s.blocker,
@@ -121,6 +122,11 @@ const createOrUpdateSubscription = async(subscription, room) => {
try {
const update = sub.prepareUpdate((s) => {
Object.assign(s, tmp);
+ if (subscription.announcement) {
+ if (subscription.announcement !== sub.announcement) {
+ s.bannerClosed = false;
+ }
+ }
});
batch.push(update);
} catch (e) {
diff --git a/app/sagas/rooms.js b/app/sagas/rooms.js
index 1b5940d1a..4575120dc 100644
--- a/app/sagas/rooms.js
+++ b/app/sagas/rooms.js
@@ -70,6 +70,11 @@ const handleRoomsRequest = function* handleRoomsRequest({ params }) {
...subsToUpdate.map((subscription) => {
const newSub = subscriptions.find(s => s._id === subscription._id);
return subscription.prepareUpdate(() => {
+ if (newSub.announcement) {
+ if (newSub.announcement !== subscription.announcement) {
+ subscription.bannerClosed = false;
+ }
+ }
Object.assign(subscription, newSub);
});
}),
diff --git a/app/views/RoomView/Banner.js b/app/views/RoomView/Banner.js
index a023fa1c6..44ae55d12 100644
--- a/app/views/RoomView/Banner.js
+++ b/app/views/RoomView/Banner.js
@@ -6,17 +6,18 @@ import Modal from 'react-native-modal';
import Markdown from '../../containers/markdown';
+import { CustomIcon } from '../../lib/Icons';
import { themes } from '../../constants/colors';
import styles from './styles';
const Banner = React.memo(({
- text, title, theme
+ text, title, theme, bannerClosed, closeBanner
}) => {
const [showModal, openModal] = useState(false);
const toggleModal = () => openModal(prevState => !prevState);
- if (text) {
+ if (text && !bannerClosed) {
return (
<>
+
+
+
prevProps.text === nextProps.text && prevProps.theme === nextProps.theme);
+}, (prevProps, nextProps) => prevProps.text === nextProps.text && prevProps.theme === nextProps.theme && prevProps.bannerClosed === nextProps.bannerClosed);
Banner.propTypes = {
text: PropTypes.string,
title: PropTypes.string,
- theme: PropTypes.string
+ theme: PropTypes.string,
+ bannerClosed: PropTypes.bool,
+ closeBanner: PropTypes.func
};
export default Banner;
diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js
index 9599e0326..345709b7f 100644
--- a/app/views/RoomView/index.js
+++ b/app/views/RoomView/index.js
@@ -69,7 +69,7 @@ const stateAttrsUpdate = [
'readOnly',
'member'
];
-const roomAttrsUpdate = ['f', 'ro', 'blocked', 'blocker', 'archived', 'muted', 'jitsiTimeout', 'announcement', 'sysMes', 'topic', 'name', 'fname', 'roles'];
+const roomAttrsUpdate = ['f', 'ro', 'blocked', 'blocker', 'archived', 'muted', 'jitsiTimeout', 'announcement', 'sysMes', 'topic', 'name', 'fname', 'roles', 'bannerClosed'];
class RoomView extends React.Component {
static navigationOptions = ({ navigation, screenProps }) => {
@@ -810,6 +810,20 @@ class RoomView extends React.Component {
}
});
+ closeBanner = async() => {
+ const { room } = this.state;
+ try {
+ const db = database.active;
+ await db.action(async() => {
+ await room.update((r) => {
+ r.bannerClosed = true;
+ });
+ });
+ } catch {
+ // do nothing
+ }
+ };
+
renderItem = (item, previousItem) => {
const { room, lastOpen, canAutoTranslate } = this.state;
const {
@@ -988,7 +1002,9 @@ class RoomView extends React.Component {
const {
user, baseUrl, theme, navigation, Hide_System_Messages
} = this.props;
- const { rid, t, sysMes } = room;
+ const {
+ rid, t, sysMes, bannerClosed, announcement
+ } = room;
return (