@norcy/react-native-toolkit 0.1.64 → 0.1.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -147,7 +147,7 @@ let isVipStateReady = false;
147
147
  let isConfigStateReady = false;
148
148
  let OnlineItems: Object[] = [];
149
149
 
150
- const _handleResponse = () => {
150
+ const _handleResponse = (customFilter?: MessageFilter) => {
151
151
  if (!isVipStateReady || !isConfigStateReady || !OnlineItems.length) {
152
152
  return;
153
153
  }
@@ -161,6 +161,9 @@ const _handleResponse = () => {
161
161
  MyMessages = _filterByVip(MyMessages);
162
162
  MyMessages = _filterByUser(MyMessages);
163
163
  MyMessages = _handleReadMessages(MyMessages);
164
+ if (customFilter) {
165
+ MyMessages = customFilter(MyMessages);
166
+ }
164
167
 
165
168
  // 由于强制插入的未读消息更改了时间,因此需要重新排序
166
169
  MyMessages = MyMessages.sort((a: Message, b: Message) => {
@@ -173,23 +176,25 @@ const _handleResponse = () => {
173
176
  MessageModel.emitChange();
174
177
  };
175
178
 
179
+ export type MessageFilter = (oldMessage: Message[]) => Message[];
180
+
176
181
  export const MessageModel = {
177
- init: () => {
182
+ init: (customFilter?: MessageFilter) => {
178
183
  ConfigDataModel.addListenerOnce(() => {
179
184
  isConfigStateReady = true;
180
- _handleResponse();
185
+ _handleResponse(customFilter);
181
186
  });
182
187
 
183
188
  // TODO 这里切换登录信息会复用
184
189
  Notification.addListenerOnce('onVipRefresh', () => {
185
190
  isVipStateReady = true;
186
- _handleResponse();
191
+ _handleResponse(customFilter);
187
192
  });
188
193
 
189
- MessageModel.fetch();
194
+ MessageModel.fetch(customFilter);
190
195
  },
191
196
 
192
- fetch: () => {
197
+ fetch: (customFilter?: MessageFilter) => {
193
198
  const query = new AV.Query('Message');
194
199
  query
195
200
  .equalTo('valid', true)
@@ -200,7 +205,7 @@ export const MessageModel = {
200
205
  .then(async (items: Object[]) => {
201
206
  console.log('Message 抓取完毕');
202
207
  OnlineItems = items;
203
- _handleResponse();
208
+ _handleResponse(customFilter);
204
209
  })
205
210
  .catch((e: any) => {
206
211
  console.error(e);
package/src/Tool.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CameraRoll } from '@react-native-camera-roll/camera-roll';
1
+ import CameraRoll from '@react-native-community/cameraroll';
2
2
  import { useState } from 'react';
3
3
  import {
4
4
  Linking,