比较提交

...

1 次代码提交

作者 SHA1 备注 提交日期
guanghuispark 6c86c9a5 fix message repeat error 3 年前
共有 1 个文件被更改,包括 42 次插入16 次删除
  1. 58
      AwesomeUIWidgets/Assets/Scripts/ChatPage.cs

58
AwesomeUIWidgets/Assets/Scripts/ChatPage.cs


{
public readonly ChatComponents.User _user = new ChatComponents.User("06c33e8b-e835-4736-80f4-63f44b66666c");
private List<ChatComponents.Message> _messages = new List<ChatComponents.Message>();
private List<ChatComponents.Message> init_messages = new List<ChatComponents.Message>();
private bool isReached = false;
public override void initState()
{

private void _addMessage(ChatComponents.Message message)
private void _addMessage(int index, ChatComponents.Message message)
_messages.Insert(0, message);
_messages.Insert(index, message);
});
}

text: message.text
);
_addMessage(textMessage);
_addMessage(0, textMessage);
private Future _handleEndReached()
{
setState(()=> {
{
_messages.AddRange(_messages);
_page = _page + 1;
}
});
return Future.value();
}
private void _loadMessages()
public List<ChatComponents.Message> InitMessages()
{
List<ChatComponents.Message> results = new List<ChatComponents.Message>();
TextAsset info = Resources.Load<TextAsset>("assets/messages");

status: ChatRoomUtils.getStatusFromString(_message.status),
text: _message.text
)
);
);
return results;
}
private Future _handleEndReached()
{
if (!isReached)
{
isReached = true;
if (init_messages.isEmpty())
{
init_messages = InitMessages();
}
return Future.delayed(TimeSpan.FromMilliseconds(1000), () =>
{
foreach (var message in init_messages)
{
_addMessage(_messages.Count, message);
}
_page = _page + 1;
isReached = false;
return Future.value();
});
}
else
{
return Future.value();
}
}
private void _loadMessages()
{
List<ChatComponents.Message> results = InitMessages();
setState(() => { _messages = results; });
}

正在加载...
取消
保存